#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 *, unsigned int, ...);
void score(unsigned r, unsigned w, unsigned g) {
  (void)printf("Rights %d, wrongs %d,", r, w);
  if (g)
    (void)printf(" extra guesses %d,", g);
  (void)printf(" score %d%%\n", (r + w + g) ? r * 100 / (r + w + g) : 0);
}


x86 assembly (clang, -O0):
<score>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
je     1150 <score+0x40>
mov    -0xc(%rbp),%esi
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
cmp    $0x0,%eax
je     117b <score+0x6b>
imul   $0x64,-0x4(%rbp),%eax
mov    -0x4(%rbp),%ecx
add    -0x8(%rbp),%ecx
add    -0xc(%rbp),%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x10(%rbp)
jmp    1185 <score+0x75>
xor    %eax,%eax
mov    %eax,-0x10(%rbp)
jmp    1185 <score+0x75>
mov    -0x10(%rbp),%esi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<score>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %esi,%ebp
mov    %edi,%r15d
lea    0xedb(%rip),%rdi
xor    %r14d,%r14d
mov    %r15d,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <printf@plt>
test   %ebx,%ebx
je     1148 <score+0x38>
lea    0xed7(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    %r15d,%ebp
add    %ebx,%ebp
je     115a <score+0x4a>
imul   $0x64,%r15d,%eax
xor    %edx,%edx
div    %ebp
mov    %eax,%r14d
lea    0xec8(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"Rights %d, wrongs %d,\00"
@.str.1 = [19 x i8] c" extra guesses %d,\00"
@.str.2 = [13 x i8] c" score %d%%\0A\00"
define void @score(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %4
%8 = load i32, i32* %5
%9 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %8)
%10 = load i32, i32* %6
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %3
%13 = load i32, i32* %6
%14 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %12, %3
%16 = load i32, i32* %4
%17 = load i32, i32* %5
%18 = add i32 %16, %17
%19 = load i32, i32* %6
%20 = add i32 %18, %19
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %31
22: ; preds = %15
%23 = load i32, i32* %4
%24 = mul i32 %23, 100
%25 = load i32, i32* %4
%26 = load i32, i32* %5
%27 = add i32 %25, %26
%28 = load i32, i32* %6
%29 = add i32 %27, %28
%30 = udiv i32 %24, %29
br label %32
31: ; preds = %15
br label %32
32: ; preds = %31, %22
%33 = phi i32 [ %30, %22 ], [ 0, %31 ]
%34 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %33)
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"Rights %d, wrongs %d,\00"
@.str.1 = [19 x i8] c" extra guesses %d,\00"
@.str.2 = [13 x i8] c" score %d%%\0A\00"
define void @score(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
%5 = icmp eq i32 %2, 0
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %2)
br label %8
8: ; preds = %6, %3
%9 = add i32 %1, %0
%10 = add i32 %9, %2
%11 = icmp eq i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %8
%13 = mul i32 %0, 100
%14 = udiv i32 %13, %10
br label %15
15: ; preds = %8, %12
%16 = phi i32 [ %14, %12 ], [ 0, %8 ]
%17 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %16)
ret void
}