#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 rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int main(void) {
  int n;
  srand(time(0));
  n = rand() - RAND_MAX / 2;
  if (n > 0) {
    printf("%d is positive\n", n);
  } else if (n == 0) {
    printf("%d is zero\n", n);
  } else {
    printf("%d is negative\n", 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,-0xc(%rbp)
mov    0x2e7a(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    11a0 <main+0x60>
mov    -0x8(%rbp),%esi
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
jmp    11d2 <main+0x92>
cmpl   $0x0,-0x8(%rbp)
jne    11be <main+0x7e>
mov    -0x8(%rbp),%esi
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
jmp    11cd <main+0x8d>
mov    -0x8(%rbp),%esi
lea    0xe54(%rip),%rdi
call   1030 <printf@plt>
jmp    11d2 <main+0x92>
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
test   %eax,%eax
jle    1177 <main+0x37>
lea    0xe8b(%rip),%rdi
jmp    1180 <main+0x40>
je     118b <main+0x4b>
lea    0xe9c(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xe7e(%rip),%rdi
xor    %esi,%esi
jmp    1182 <main+0x42>

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

LLVM IR (-O2):
@RAND_MAX = global i32 0
@.str = [16 x i8] c"%d is positive\0A\00"
@.str.1 = [12 x i8] c"%d is zero\0A\00"
@.str.2 = [16 x i8] c"%d is negative\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 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %6)
br label %16
10: ; preds = %0
%11 = icmp eq i32 %6, 0
br i1 %11, label %12, label %14
12: ; preds = %10
%13 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 0)
br label %16
14: ; preds = %10
%15 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %6)
br label %16
16: ; preds = %12, %14, %8
ret i32 0
}