#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(unsigned int *, int, int, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int random();
int /*<<< orphan*/ srandom(unsigned int);
int main(int argc, char *argv[]) {
  int questions, answers, tests, correct, *key;
  int i, j;
  unsigned int seeder;
  FILE *rnd_file;
  if (argc != 4) {
    printf("usage: %s <questions> <answers> <tests>\n", argv[0]);
    exit(1);
  }
  questions = atoi(argv[1]);
  answers = atoi(argv[2]);
  tests = atoi(argv[3]);
  rnd_file = fopen("/dev/urandom", "r");
  fread(&seeder, 1, 8, rnd_file);
  srandom(seeder);
  fclose(rnd_file);
  key = (int *)malloc(questions * sizeof(*key));
  for (i = 0; i < questions; i++)
    key[i] = random() % answers + 1;
  for (i = 0; i < tests; i++) {
    correct = 0;
    for (j = 0; j < questions; j++)
      if ((random() % answers + 1) == key[j])
        correct++;
    printf("%0.0f\n", ((float)correct / questions) * 100);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     11cf <main+0x3f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
lea    0xe27(%rip),%rdi
lea    0xe2d(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rcx
lea    -0x34(%rbp),%rdi
mov    $0x1,%esi
mov    $0x8,%edx
call   1040 <fread@plt>
mov    -0x34(%rbp),%edi
call   1030 <srandom@plt>
mov    -0x40(%rbp),%rdi
call   1050 <fclose@plt>
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    128b <main+0xfb>
mov    $0x0,%al
call   1070 <random@plt>
cltd
idivl  -0x18(%rbp)
add    $0x1,%edx
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1258 <main+0xc8>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    132d <main+0x19d>
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12f3 <main+0x163>
mov    $0x0,%al
call   1070 <random@plt>
cltd
idivl  -0x18(%rbp)
add    $0x1,%edx
mov    -0x28(%rbp),%rax
movslq -0x30(%rbp),%rcx
cmp    (%rax,%rcx,4),%edx
jne    12e0 <main+0x150>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    12e5 <main+0x155>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    12ac <main+0x11c>
cvtsi2ssl -0x20(%rbp),%xmm0
cvtsi2ssl -0x14(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  0xcf7(%rip),%xmm1
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd24(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1292 <main+0x102>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
cmp    $0x4,%edi
jne    12f6 <main+0x166>
mov    0x8(%rbx),%rdi
call   10a0 <atoi@plt>
mov    %eax,%r14d
mov    0x10(%rbx),%rdi
call   10a0 <atoi@plt>
mov    %eax,%r13d
mov    0x18(%rbx),%rdi
call   10a0 <atoi@plt>
mov    %eax,0x4(%rsp)
lea    0xe57(%rip),%rdi
lea    0xe5d(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
lea    0xc(%rsp),%rdi
mov    $0x1,%esi
mov    $0x8,%edx
mov    %rax,%rcx
call   1040 <fread@plt>
mov    0xc(%rsp),%edi
call   1030 <srandom@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
lea    0x0(,%r14,4),%edi
call   1080 <malloc@plt>
mov    %rax,%r12
mov    %r14d,%ebp
mov    %r14,0x10(%rsp)
test   %r14d,%r14d
jle    124b <main+0xbb>
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1070 <random@plt>
cltd
idiv   %r13d
add    $0x1,%edx
mov    %edx,(%r12,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1230 <main+0xa0>
cmpl   $0x0,0x4(%rsp)
jle    12e5 <main+0x155>
cvtsi2ssl 0x10(%rsp),%xmm0
movss  %xmm0,0x8(%rsp)
xor    %ebx,%ebx
jmp    12a1 <main+0x111>
cs nopw 0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2ss %r14d,%xmm0
divss  0x8(%rsp),%xmm0
mulss  0xd7a(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdab(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
add    $0x1,%ebx
cmp    0x4(%rsp),%ebx
je     12e5 <main+0x155>
mov    $0x0,%r14d
cmpl   $0x0,0x10(%rsp)
jle    1270 <main+0xe0>
xor    %r15d,%r15d
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1070 <random@plt>
cltd
idiv   %r13d
add    $0x1,%edx
xor    %eax,%eax
cmp    (%r12,%r15,4),%edx
sete   %al
add    %eax,%r14d
add    $0x1,%r15
cmp    %r15,%rbp
jne    12c0 <main+0x130>
jmp    1270 <main+0xe0>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rbx),%rsi
lea    0xd04(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [41 x i8] c"usage: %s <questions> <answers> <tests>\0A\00"
@.str.1 = [13 x i8] c"/dev/urandom\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [7 x i8] c"%0.0f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 4
br i1 %16, label %17, label %23
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 @atoi(i8* %26)
store i32 %27, i32* %6
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 2
%30 = load i8*, i8** %29
%31 = call i32 @atoi(i8* %30)
store i32 %31, i32* %7
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 3
%34 = load i8*, i8** %33
%35 = call i32 @atoi(i8* %34)
store i32 %35, i32* %8
%36 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %36, i32** %14
%37 = load i32*, i32** %14
%38 = call i32 @fread(i32* %13, i32 1, i32 8, i32* %37)
%39 = load i32, i32* %13
%40 = call i32 @srandom(i32 %39)
%41 = load i32*, i32** %14
%42 = call i32 @fclose(i32* %41)
%43 = load i32, i32* %6
%44 = sext i32 %43 to i64
%45 = mul i64 %44, 4
%46 = trunc i64 %45 to i32
%47 = call i64 @malloc(i32 %46)
%48 = inttoptr i64 %47 to i32*
store i32* %48, i32** %10
store i32 0, i32* %11
br label %49
49: ; preds = %62, %23
%50 = load i32, i32* %11
%51 = load i32, i32* %6
%52 = icmp slt i32 %50, %51
br i1 %52, label %53, label %65
53: ; preds = %49
%54 = call i32 (...) @random()
%55 = load i32, i32* %7
%56 = srem i32 %54, %55
%57 = add nsw i32 %56, 1
%58 = load i32*, i32** %10
%59 = load i32, i32* %11
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i32, i32* %58, i64 %60
store i32 %57, i32* %61
br label %62
62: ; preds = %53
%63 = load i32, i32* %11
%64 = add nsw i32 %63, 1
store i32 %64, i32* %11
br label %49
65: ; preds = %49
store i32 0, i32* %11
br label %66
66: ; preds = %102, %65
%67 = load i32, i32* %11
%68 = load i32, i32* %8
%69 = icmp slt i32 %67, %68
br i1 %69, label %70, label %105
70: ; preds = %66
store i32 0, i32* %9
store i32 0, i32* %12
br label %71
71: ; preds = %90, %70
%72 = load i32, i32* %12
%73 = load i32, i32* %6
%74 = icmp slt i32 %72, %73
br i1 %74, label %75, label %93
75: ; preds = %71
%76 = call i32 (...) @random()
%77 = load i32, i32* %7
%78 = srem i32 %76, %77
%79 = add nsw i32 %78, 1
%80 = load i32*, i32** %10
%81 = load i32, i32* %12
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds i32, i32* %80, i64 %82
%84 = load i32, i32* %83
%85 = icmp eq i32 %79, %84
br i1 %85, label %86, label %89
86: ; preds = %75
%87 = load i32, i32* %9
%88 = add nsw i32 %87, 1
store i32 %88, i32* %9
br label %89
89: ; preds = %86, %75
br label %90
90: ; preds = %89
%91 = load i32, i32* %12
%92 = add nsw i32 %91, 1
store i32 %92, i32* %12
br label %71
93: ; preds = %71
%94 = load i32, i32* %9
%95 = sitofp i32 %94 to float
%96 = load i32, i32* %6
%97 = sitofp i32 %96 to float
%98 = fdiv float %95, %97
%99 = fmul float %98, 1.000000e+02
%100 = fpext float %99 to double
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double %100)
br label %102
102: ; preds = %93
%103 = load i32, i32* %11
%104 = add nsw i32 %103, 1
store i32 %104, i32* %11
br label %66
105: ; preds = %66
ret i32 0
}

LLVM IR (-O2):
@.str = [41 x i8] c"usage: %s <questions> <answers> <tests>\0A\00"
@.str.1 = [13 x i8] c"/dev/urandom\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [7 x i8] c"%0.0f\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp eq i32 %0, 4
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = tail call i32 @atoi(i8* %15)
%17 = getelementptr inbounds i8*, i8** %1, i64 3
%18 = load i8*, i8** %17
%19 = tail call i32 @atoi(i8* %18)
%20 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @fread(i32* %3, i32 1, i32 8, i32* %20)
%22 = load i32, i32* %3
%23 = tail call i32 @srandom(i32 %22)
%24 = tail call i32 @fclose(i32* %20)
%25 = shl i32 %13, 2
%26 = tail call i64 @malloc(i32 %25)
%27 = inttoptr i64 %26 to i32*
%28 = icmp sgt i32 %13, 0
br i1 %28, label %29, label %31
29: ; preds = %10
%30 = zext i32 %13 to i64
br label %36
31: ; preds = %36, %10
%32 = icmp sgt i32 %19, 0
br i1 %32, label %33, label %68
33: ; preds = %31
%34 = sitofp i32 %13 to float
%35 = zext i32 %13 to i64
br label %44
36: ; preds = %29, %36
%37 = phi i64 [ 0, %29 ], [ %42, %36 ]
%38 = tail call i32 (...) @random()
%39 = srem i32 %38, %16
%40 = add nsw i32 %39, 1
%41 = getelementptr inbounds i32, i32* %27, i64 %37
store i32 %40, i32* %41
%42 = add nuw nsw i64 %37, 1
%43 = icmp eq i64 %42, %30
br i1 %43, label %31, label %36
44: ; preds = %33, %59
%45 = phi i32 [ 0, %33 ], [ %66, %59 ]
br i1 %28, label %46, label %59
46: ; preds = %44, %46
%47 = phi i64 [ %57, %46 ], [ 0, %44 ]
%48 = phi i32 [ %56, %46 ], [ 0, %44 ]
%49 = tail call i32 (...) @random()
%50 = srem i32 %49, %16
%51 = add nsw i32 %50, 1
%52 = getelementptr inbounds i32, i32* %27, i64 %47
%53 = load i32, i32* %52
%54 = icmp eq i32 %51, %53
%55 = zext i1 %54 to i32
%56 = add nuw nsw i32 %48, %55
%57 = add nuw nsw i64 %47, 1
%58 = icmp eq i64 %57, %35
br i1 %58, label %59, label %46
59: ; preds = %46, %44
%60 = phi i32 [ 0, %44 ], [ %56, %46 ]
%61 = sitofp i32 %60 to float
%62 = fdiv float %61, %34
%63 = fmul float %62, 1.000000e+02
%64 = fpext float %63 to double
%65 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double %64)
%66 = add nuw nsw i32 %45, 1
%67 = icmp eq i32 %66, %19
br i1 %67, label %68, label %44
68: ; preds = %59, %31
ret i32 0
}