Created
May 20, 2009 01:53
-
-
Save bdonlan/114562 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <limits.h> | |
#include <stdlib.h> | |
size_t tmul(int x, int y) { | |
long long tv = (long long)x * (long long)y; | |
if (tv < 0 || tv > UINT_MAX) | |
return -1; | |
return tv; | |
} | |
.file "test2.c" | |
.text | |
.p2align 4,,15 | |
.globl tmul | |
.type tmul, @function | |
tmul: | |
pushl %ebp | |
movl $-1, %ecx | |
movl %esp, %ebp | |
movl 12(%ebp), %eax | |
imull 8(%ebp) | |
cmpl $0, %edx | |
ja .L3 | |
movl %eax, %ecx | |
.L3: | |
movl %ecx, %eax | |
popl %ebp | |
ret | |
.size tmul, .-tmul | |
.ident "GCC: (Ubuntu 4.3.3-5ubuntu4) 4.3.3" | |
.section .note.GNU-stack,"",@progbits |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment