#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int RAND_MAX;
int /*<<< orphan*/ printf(char *, int, int);
int rand();
int reverse(int);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  int i, c;
  srand(time(NULL));
  for (c = 0; c < 10; c++) {
    i = rand() % 100000;
    if (rand() < RAND_MAX / 2)
      i *= -1;
    printf("%6d  \t->  \t%6d\n", i, reverse(i));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    11ee <main+0x9e>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x186a0,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    %eax,-0x10(%rbp)
mov    0x2e45(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
jge    11c1 <main+0x71>
imul   $0xffffffff,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <reverse@plt>
mov    -0x14(%rbp),%esi
mov    %eax,%edx
lea    0xe25(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1176 <main+0x26>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    $0xa,%r12d
mov    0x2e75(%rip),%r15
lea    0xe86(%rip),%r14
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <rand@plt>
movslq %eax,%rbx
imul   $0x14f8b589,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x2d,%rax
add    %ecx,%eax
imul   $0x186a0,%eax,%eax
sub    %eax,%ebx
xor    %eax,%eax
call   1070 <rand@plt>
mov    (%r15),%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
add    %ecx,%edx
sar    %edx
mov    %ebx,%ebp
neg    %ebp
cmp    %edx,%eax
cmovge %ebx,%ebp
mov    %ebp,%edi
call   1030 <reverse@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1040 <printf@plt>
add    $0xffffffff,%r12d
jne    1180 <main+0x30>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@RAND_MAX = global i32 0
@.str = [16 x i8] c"%6d \09-> \09%6d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @time(i32* null)
%5 = call i32 @srand(i32 %4)
store i32 0, i32* %3
br label %6
6: ; preds = %24, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 10
br i1 %8, label %9, label %27
9: ; preds = %6
%10 = call i32 (...) @rand()
%11 = srem i32 %10, 100000
store i32 %11, i32* %2
%12 = call i32 (...) @rand()
%13 = load i32, i32* @RAND_MAX
%14 = sdiv i32 %13, 2
%15 = icmp slt i32 %12, %14
br i1 %15, label %16, label %19
16: ; preds = %9
%17 = load i32, i32* %2
%18 = mul nsw i32 %17, -1
store i32 %18, i32* %2
br label %19
19: ; preds = %16, %9
%20 = load i32, i32* %2
%21 = load i32, i32* %2
%22 = call i32 @reverse(i32 %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %20, i32 %22)
br label %24
24: ; preds = %19
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %6
27: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@RAND_MAX = global i32 0
@.str = [16 x i8] c"%6d \09-> \09%6d\0A\00"
define i32 @main() {
%1 = tail call i32 @time(i32* null)
%2 = tail call i32 @srand(i32 %1)
br label %3
3: ; preds = %0, %3
%4 = phi i32 [ 0, %0 ], [ %15, %3 ]
%5 = tail call i32 (...) @rand()
%6 = srem i32 %5, 100000
%7 = tail call i32 (...) @rand()
%8 = load i32, i32* @RAND_MAX
%9 = sdiv i32 %8, 2
%10 = icmp slt i32 %7, %9
%11 = sub nsw i32 0, %6
%12 = select i1 %10, i32 %11, i32 %6
%13 = tail call i32 @reverse(i32 %12)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %13)
%15 = add nuw nsw i32 %4, 1
%16 = icmp eq i32 %15, 10
br i1 %16, label %17, label %3
17: ; preds = %3
ret i32 0
}