#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 rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int main(void) {
  int n;
  int lastnum;
  srand(time(0));
  n = rand() - RAND_MAX / 2;
  lastnum = n % 10;
  printf("Last digit of %d is %d ", n, lastnum);
  if (lastnum > 5) {
    printf("and is greater than 5\n");
  } else if (lastnum == 0) {
    printf("and is 0\n");
  } else {
    printf("and is less than 6 and not 0\n");
  }
  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)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x5,-0xc(%rbp)
jle    11c1 <main+0x81>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f1 <main+0xb1>
cmpl   $0x0,-0xc(%rbp)
jne    11de <main+0x9e>
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ec <main+0xac>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f1 <main+0xb1>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
xor    %eax,%eax
call   1070 <rand@plt>
mov    0x2e7b(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
add    %ecx,%edx
sar    %edx
sub    %edx,%eax
movslq %eax,%rsi
imul   $0x66666667,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
mov    %esi,%ebx
sub    %eax,%ebx
lea    0xe5f(%rip),%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
lea    0xe82(%rip),%rax
lea    0xe5e(%rip),%rcx
cmove  %rax,%rcx
cmp    $0x6,%ebx
lea    0xe76(%rip),%rdi
cmovl  %rcx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@RAND_MAX = global i32 0
@.str = [24 x i8] c"Last digit of %d is %d \00"
@.str.1 = [23 x i8] c"and is greater than 5\0A\00"
@.str.2 = [10 x i8] c"and is 0\0A\00"
@.str.3 = [30 x i8] c"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* %2
%13 = load i32, i32* %3
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %13)
%15 = load i32, i32* %3
%16 = icmp sgt i32 %15, 5
br i1 %16, label %17, label %19
17: ; preds = %0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %27
19: ; preds = %0
%20 = load i32, i32* %3
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %26
24: ; preds = %19
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
br label %26
26: ; preds = %24, %22
br label %27
27: ; preds = %26, %17
ret i32 0
}

LLVM IR (-O2):
@RAND_MAX = global i32 0
@.str = [24 x i8] c"Last digit of %d is %d \00"
@str = [29 x i8] c"and is less than 6 and not 0\00"
@str.4 = [9 x i8] c"and is 0\00"
@str.5 = [22 x i8] c"and is greater than 5\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 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %7)
%9 = icmp sgt i32 %7, 5
%10 = icmp eq i32 %7, 0
%11 = select i1 %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str.4, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0)
%12 = select i1 %9, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @str.5, i64 0, i64 0), i8* %11
%13 = tail call i32 @puts(i8* dereferenceable(1) %12)
ret i32 0
}