#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 /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int main(void) {
  int n;
  int i;
  srand(time(0));
  n = rand() - RAND_MAX / 2;
  i = n % 10;
  if (i > 5) {
    printf("Last digit of %i is %i and is greater than 5\n", n, i);
  } else if (i == 0) {
    printf("Last digit of %i is %i and is 0\n", n, i);
  } else {
    printf("Last digit of %i is %i and is less than 6 and not 0\n", n, i);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0x0,%al
call   1060 <rand@plt>
mov    %eax,-0x10(%rbp)
mov    0x2e7a(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
cmpl   $0x5,-0xc(%rbp)
jle    11b1 <main+0x71>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe59(%rip),%rdi
call   1030 <printf@plt>
jmp    11e9 <main+0xa9>
cmpl   $0x0,-0xc(%rbp)
jne    11d2 <main+0x92>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe66(%rip),%rdi
call   1030 <printf@plt>
jmp    11e4 <main+0xa4>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe70(%rip),%rdi
call   1030 <printf@plt>
jmp    11e9 <main+0xa9>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
xor    %eax,%eax
call   1060 <rand@plt>
mov    0x2e8b(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
add    %ecx,%edx
sar    %edx
sub    %edx,%eax
movslq %eax,%rdx
imul   $0x66666667,%rdx,%rcx
mov    %rcx,%rsi
shr    $0x3f,%rsi
sar    $0x22,%rcx
add    %esi,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%edx
cmp    $0x6,%edx
jl     1196 <main+0x56>
lea    0xe6c(%rip),%rdi
jmp    11a1 <main+0x61>
test   %edx,%edx
je     11a5 <main+0x65>
lea    0xeae(%rip),%rdi
mov    %eax,%esi
jmp    11b0 <main+0x70>
lea    0xe82(%rip),%rdi
mov    %eax,%esi
xor    %edx,%edx
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@RAND_MAX = global i32 0
@.str = [46 x i8] c"Last digit of %i is %i and is greater than 5\0A\00"
@.str.1 = [33 x i8] c"Last digit of %i is %i and is 0\0A\00"
@.str.2 = [53 x i8] c"Last digit of %i is %i and is less than 6 and not 0\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @time(i32 0)
%5 = call i32 @srand(i32 %4)
%6 = call i32 (...) @rand()
%7 = load i32, i32* @RAND_MAX
%8 = sdiv i32 %7, 2
%9 = sub nsw i32 %6, %8
store i32 %9, i32* %2
%10 = load i32, i32* %2
%11 = srem i32 %10, 10
store i32 %11, i32* %3
%12 = load i32, i32* %3
%13 = icmp sgt i32 %12, 5
br i1 %13, label %14, label %18
14: ; preds = %0
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16)
br label %30
18: ; preds = %0
%19 = load i32, i32* %3
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %18
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %23)
br label %29
25: ; preds = %18
%26 = load i32, i32* %2
%27 = load i32, i32* %3
%28 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i32 %26, i32 %27)
br label %29
29: ; preds = %25, %21
br label %30
30: ; preds = %29, %14
ret i32 0
}

LLVM IR (-O2):
@RAND_MAX = global i32 0
@.str = [46 x i8] c"Last digit of %i is %i and is greater than 5\0A\00"
@.str.1 = [33 x i8] c"Last digit of %i is %i and is 0\0A\00"
@.str.2 = [53 x i8] c"Last digit of %i is %i and is less than 6 and not 0\0A\00"
define i32 @main() {
%1 = tail call i32 @time(i32 0)
%2 = tail call i32 @srand(i32 %1)
%3 = tail call i32 (...) @rand()
%4 = load i32, i32* @RAND_MAX
%5 = sdiv i32 %4, -2
%6 = add i32 %5, %3
%7 = srem i32 %6, 10
%8 = icmp sgt i32 %7, 5
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = tail call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %7)
br label %17
11: ; preds = %0
%12 = icmp eq i32 %7, 0
br i1 %12, label %13, label %15
13: ; preds = %11
%14 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 0)
br label %17
15: ; preds = %11
%16 = tail call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i32 %6, i32 %7)
br label %17
17: ; preds = %13, %15, %9
ret i32 0
}