#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 calculate_result(int *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int balls[6];
  int count_balls = 0;
  int favourite = 0;
  for (int i = 1; i < argc; i++) {
    goto usage_error;
  }
  int power_ball = balls[5];
  int result = calculate_result(balls, power_ball);
  if (result < 0) {
    goto usage_error;
  }
  if (7 == power_ball) {
    result = result * 2;
  }
  if (favourite) {
    result = result * 2;
  }
  printf("%d percent chance of winning\n", result);
  return 0;
usage_error:
  fprintf(stderr, "Usage: %s [-favourite] (5 white balls) power_ball\n",
          argv[0]);
  return -1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x1,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    116c <main+0x3c>
jmp    11d5 <main+0xa5>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x40(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x40(%rbp),%esi
call   1050 <calculate_result@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jge    1190 <main+0x60>
jmp    11d5 <main+0xa5>
mov    $0x7,%eax
cmp    -0x40(%rbp),%eax
jne    11a7 <main+0x77>
mov    -0x44(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x38(%rbp)
je     11ba <main+0x8a>
mov    -0x44(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%esi
lea    0xe3c(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11f8 <main+0xc8>
mov    0x2e04(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe32(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     115b <main+0x2b>
mov    %rsp,%rdi
call   1050 <calculate_result@plt>
test   %eax,%eax
js     115b <main+0x2b>
lea    0xeb0(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
jmp    1178 <main+0x48>
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xeb0(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [30 x i8] c"%d percent chance of winning\0A\00"
@stderr = global i32 0
@.str.1 = [51 x i8] c"Usage: %s [-favourite] (5 white balls) power_ball\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [6 x i32]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 0, i32* %8
store i32 1, i32* %9
br label %12
12: ; preds = %17, %2
%13 = load i32, i32* %9
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %20
16: ; preds = %12
br label %44
17: ; No predecessors!
%18 = load i32, i32* %9
%19 = add nsw i32 %18, 1
store i32 %19, i32* %9
br label %12
20: ; preds = %12
%21 = getelementptr inbounds [6 x i32], [6 x i32]* %6, i64 0, i64 5
%22 = load i32, i32* %21
store i32 %22, i32* %10
%23 = getelementptr inbounds [6 x i32], [6 x i32]* %6, i64 0, i64 0
%24 = load i32, i32* %10
%25 = call i32 @calculate_result(i32* %23, i32 %24)
store i32 %25, i32* %11
%26 = load i32, i32* %11
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %20
br label %44
29: ; preds = %20
%30 = load i32, i32* %10
%31 = icmp eq i32 7, %30
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = load i32, i32* %11
%34 = mul nsw i32 %33, 2
store i32 %34, i32* %11
br label %35
35: ; preds = %32, %29
%36 = load i32, i32* %8
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %35
%39 = load i32, i32* %11
%40 = mul nsw i32 %39, 2
store i32 %40, i32* %11
br label %41
41: ; preds = %38, %35
%42 = load i32, i32* %11
%43 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %42)
store i32 0, i32* %3
br label %50
44: ; preds = %28, %16
%45 = load i32, i32* @stderr
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 0
%48 = load i8*, i8** %47
%49 = call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i8* %48)
store i32 -1, i32* %3
br label %50
50: ; preds = %44, %41
%51 = load i32, i32* %3
ret i32 %51
}

LLVM IR (-O2):
@.str = [30 x i8] c"%d percent chance of winning\0A\00"
@stderr = global i32 0
@.str.1 = [51 x i8] c"Usage: %s [-favourite] (5 white balls) power_ball\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [6 x i32]
%4 = bitcast [6 x i32]* %3 to i8*
%5 = icmp sgt i32 %0, 1
br i1 %5, label %12, label %6
6: ; preds = %2
%7 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
%8 = call i32 @calculate_result(i32* %7, i32 undef)
%9 = icmp slt i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %8)
br label %16
12: ; preds = %2, %6
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %1
%15 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %12, %10
%17 = phi i32 [ -1, %12 ], [ 0, %10 ]
ret i32 %17
}