#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();
void election_results(int length, char *flag_to_give, char *result) {
  int votes = rand() % 100;
  printf("Here are the results:\n");
  printf("You got %d votes!\n", votes);
  if (votes > 500) {
    printf("You win!");
  } else {
    printf(result);
  }
}


x86 assembly (clang, -O0):
<election_results>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1f4,-0x1c(%rbp)
jle    1184 <election_results+0x64>
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    118f <election_results+0x6f>
mov    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<election_results>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
xor    %eax,%eax
call   1050 <rand@plt>
movslq %eax,%rbx
imul   $0x51eb851f,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%ebx
lea    0xeb2(%rip),%rdi
call   1030 <puts@plt>
lea    0xe93(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"Here are the results:\0A\00"
@.str.1 = [19 x i8] c"You got %d votes!\0A\00"
@.str.2 = [9 x i8] c"You win!\00"
define void @election_results(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = call i32 (...) @rand()
%9 = srem i32 %8, 100
store i32 %9, i32* %7
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* %7
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = load i32, i32* %7
%14 = icmp sgt i32 %13, 500
br i1 %14, label %15, label %17
15: ; preds = %3
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %20
17: ; preds = %3
%18 = load i8*, i8** %6
%19 = call i32 (i8*, ...) @printf(i8* %18)
br label %20
20: ; preds = %17, %15
ret void
}

LLVM IR (-O2):
@.str.1 = [19 x i8] c"You got %d votes!\0A\00"
@str = [22 x i8] c"Here are the results:\00"
define void @election_results(i32 %0, i8* nocapture readnone %1, i8* nocapture %2) {
%4 = tail call i32 (...) @rand()
%5 = srem i32 %4, 100
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %2)
ret void
}