#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 rand();
int /*<<< orphan*/ sscanf(char *, char *, int *);
int genKey() {
  char number[5];
  int m, x, max, min, key;
  max = 6;
  min = 1;
  key = 0;
  for (x = 0; x < 5; x++) {
    number[x] = '0' + (rand() % (max - min) + min);
  }
  sscanf(number, "%d", &key);
  return key;
}


x86 assembly (clang, -O0):
<genKey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x6,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x5,-0x10(%rbp)
jge    117e <genKey+0x5e>
mov    $0x0,%al
call   1040 <rand@plt>
mov    -0x14(%rbp),%ecx
sub    -0x18(%rbp),%ecx
cltd
idiv   %ecx
mov    %edx,%eax
add    -0x18(%rbp),%eax
add    $0x30,%eax
mov    %al,%cl
movslq -0x10(%rbp),%rax
mov    %cl,-0x5(%rbp,%rax,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1144 <genKey+0x24>
lea    -0x5(%rbp),%rdi
lea    0xe77(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1030 <sscanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<genKey>:
sub    $0x18,%rsp
movl   $0x0,0x14(%rsp)
xor    %eax,%eax
call   1040 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
add    $0x31,%al
mov    %al,0xf(%rsp)
xor    %eax,%eax
call   1040 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
add    $0x31,%al
mov    %al,0x10(%rsp)
xor    %eax,%eax
call   1040 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
add    $0x31,%al
mov    %al,0x11(%rsp)
xor    %eax,%eax
call   1040 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
add    $0x31,%al
mov    %al,0x12(%rsp)
xor    %eax,%eax
call   1040 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
add    $0x31,%al
mov    %al,0x13(%rsp)
lea    0xe05(%rip),%rsi
lea    0xf(%rsp),%rdi
lea    0x14(%rsp),%rdx
call   1030 <sscanf@plt>
mov    0x14(%rsp),%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @genKey() {
%1 = alloca [5 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 6, i32* %4
store i32 1, i32* %5
store i32 0, i32* %6
store i32 0, i32* %3
br label %7
7: ; preds = %23, %0
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 5
br i1 %9, label %10, label %26
10: ; preds = %7
%11 = call i32 (...) @rand()
%12 = load i32, i32* %4
%13 = load i32, i32* %5
%14 = sub nsw i32 %12, %13
%15 = srem i32 %11, %14
%16 = load i32, i32* %5
%17 = add nsw i32 %15, %16
%18 = add nsw i32 48, %17
%19 = trunc i32 %18 to i8
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 %21
store i8 %19, i8* %22
br label %23
23: ; preds = %10
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %7
26: ; preds = %7
%27 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%28 = call i32 @sscanf(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%29 = load i32, i32* %6
ret i32 %29
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @genKey() {
%1 = alloca [5 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%5 = tail call i32 (...) @rand()
%6 = srem i32 %5, 5
%7 = trunc i32 %6 to i8
%8 = add nsw i8 %7, 49
store i8 %8, i8* %3
%9 = tail call i32 (...) @rand()
%10 = srem i32 %9, 5
%11 = trunc i32 %10 to i8
%12 = add nsw i8 %11, 49
%13 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 1
store i8 %12, i8* %13
%14 = tail call i32 (...) @rand()
%15 = srem i32 %14, 5
%16 = trunc i32 %15 to i8
%17 = add nsw i8 %16, 49
%18 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 2
store i8 %17, i8* %18
%19 = tail call i32 (...) @rand()
%20 = srem i32 %19, 5
%21 = trunc i32 %20 to i8
%22 = add nsw i8 %21, 49
%23 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 3
store i8 %22, i8* %23
%24 = tail call i32 (...) @rand()
%25 = srem i32 %24, 5
%26 = trunc i32 %25 to i8
%27 = add nsw i8 %26, 49
%28 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 4
store i8 %27, i8* %28
%29 = call i32 @sscanf(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%30 = load i32, i32* %2
ret i32 %30
}