#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 /*<<< orphan*/ printf(char *);
int rand();
int pitch_result(void) {
  int result = rand() % 4;
  if (result >= 2) {
    printf("Strike!\n");
    return 0;
  } else if (result >= 1) {
    printf("hit!\n");
    return 1;
  }
  printf("hit!\n");
  return 2;
}


x86 assembly (clang, -O0):
<pitch_result>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     115c <pitch_result+0x3c>
lea    0xeb5(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1196 <pitch_result+0x76>
cmpl   $0x1,-0x8(%rbp)
jl     117e <pitch_result+0x5e>
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1196 <pitch_result+0x76>
jmp    1183 <pitch_result+0x63>
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pitch_result>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <rand@plt>
lea    0x3(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffffc,%ecx
sub    %ecx,%eax
xor    %ecx,%ecx
cmp    $0x1,%eax
sete   %cl
mov    $0x2,%ebx
sub    %ecx,%ebx
cmp    $0x2,%eax
lea    0xeae(%rip),%rax
lea    0xeac(%rip),%rdi
cmovl  %rax,%rdi
cmovge %ebp,%ebx
call   1030 <puts@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"Strike!\0A\00"
@.str.1 = [6 x i8] c"hit!\0A\00"
define i32 @pitch_result() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (...) @rand()
%4 = srem i32 %3, 4
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp sge i32 %5, 2
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %17
9: ; preds = %0
%10 = load i32, i32* %2
%11 = icmp sge i32 %10, 1
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %17
14: ; preds = %9
br label %15
15: ; preds = %14
%16 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 2, i32* %1
br label %17
17: ; preds = %15, %12, %7
%18 = load i32, i32* %1
ret i32 %18
}

LLVM IR (-O2):
@str.2 = [5 x i8] c"hit!\00"
@str.3 = [8 x i8] c"Strike!\00"
define i32 @pitch_result() {
%1 = tail call i32 (...) @rand()
%2 = srem i32 %1, 4
%3 = icmp sgt i32 %2, 1
%4 = icmp eq i32 %2, 1
%5 = select i1 %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @str.2, i64 0, i64 0)
%6 = select i1 %4, i32 1, i32 2
%7 = select i1 %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @str.3, i64 0, i64 0), i8* %5
%8 = select i1 %3, i32 0, i32 %6
%9 = tail call i32 @puts(i8* dereferenceable(1) %7)
ret i32 %8
}