#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 */
struct timeval {
  long tv_usec;
  int tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ srand(long);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ timersub(struct timeval *, struct timeval *,
                            struct timeval *);
int main(int argc, char *argv[]) {
  char startAlph[27] = "abcdefghijklmnopqrstuvwxyz";
  char tempChar1;
  char tempChar2;
  int tempLoc1;
  int tempLoc2;
  char typedChar[27];
  struct timeval programTime;
  struct timeval loopTime;
  struct timeval doneTime;
  gettimeofday(&programTime, NULL);
  srand(programTime.tv_usec);
  for (int i = 0; i < 13; i++) {
    tempChar1 = startAlph[tempLoc1 = (rand() % 26)];
    tempChar2 = startAlph[tempLoc2 = (rand() % 26)];
    startAlph[tempLoc1] = tempChar2;
    startAlph[tempLoc2] = tempChar1;
  }
  do {
    gettimeofday(&loopTime, NULL);
    printf("Type the following string (followed by <enter>):\n%s\n", startAlph);
    scanf("%s", &typedChar[0]);
    if (strcmp(startAlph, typedChar) == 0) {
      printf("\nCorrect!\n");
      break;
    }
    printf("\nIncorrect. Try again.\n");
  } while (1);
  gettimeofday(&doneTime, NULL);
  timersub(&doneTime, &loopTime, &loopTime);
  timersub(&doneTime, &programTime, &doneTime);
  int progDiffTime = doneTime.tv_sec;
  long progDiffTimeUsec = doneTime.tv_usec;
  int loopDiffTime = loopTime.tv_sec;
  long loopDiffTimeUsec = loopTime.tv_usec;
  printf("It took you %d seconds (%ld microseconds) to type the whole thing "
         "correctly!\n",
         progDiffTime, progDiffTimeUsec);
  printf("It took you %d seconds (%ld microseconds) to type it correctly the "
         "last time!\n",
         loopDiffTime, loopDiffTimeUsec);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe70(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe6d(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe6a(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe67(%rip),%ax
mov    %ax,-0x18(%rbp)
mov    0xe5f(%rip),%al
mov    %al,-0x16(%rbp)
lea    -0x70(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
mov    -0x70(%rbp),%rdi
call   1050 <srand@plt>
movl   $0x0,-0x94(%rbp)
cmpl   $0xd,-0x94(%rbp)
jge    124d <main+0xdd>
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    %edx,-0x38(%rbp)
movslq %edx,%rax
mov    -0x30(%rbp,%rax,1),%al
mov    %al,-0x31(%rbp)
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    %edx,-0x3c(%rbp)
movslq %edx,%rax
mov    -0x30(%rbp,%rax,1),%al
mov    %al,-0x32(%rbp)
mov    -0x32(%rbp),%cl
movslq -0x38(%rbp),%rax
mov    %cl,-0x30(%rbp,%rax,1)
mov    -0x31(%rbp),%cl
movslq -0x3c(%rbp),%rax
mov    %cl,-0x30(%rbp,%rax,1)
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    11de <main+0x6e>
jmp    1252 <main+0xe2>
lea    -0x80(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
lea    -0x30(%rbp),%rsi
lea    0xdb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x60(%rbp),%rsi
lea    0xdd4(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x30(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12ab <main+0x13b>
lea    0xdb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c8 <main+0x158>
lea    0xdac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%al
test   $0x1,%al
jne    1252 <main+0xe2>
jmp    12c8 <main+0x158>
lea    -0x90(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
lea    -0x90(%rbp),%rdi
lea    -0x80(%rbp),%rdx
mov    %rdx,%rsi
call   1080 <timersub@plt>
lea    -0x90(%rbp),%rdx
lea    -0x70(%rbp),%rsi
mov    %rdx,%rdi
call   1080 <timersub@plt>
mov    -0x88(%rbp),%eax
mov    %eax,-0x98(%rbp)
mov    -0x90(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x78(%rbp),%eax
mov    %eax,-0xa4(%rbp)
mov    -0x80(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x98(%rbp),%esi
mov    -0xa0(%rbp),%rdx
lea    0xd36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xa4(%rbp),%esi
mov    -0xb0(%rbp),%rdx
lea    0xd69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
movups 0xe76(%rip),%xmm0
movups %xmm0,0x1b(%rsp)
movaps 0xe5f(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x40(%rsp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    0x40(%rsp),%rdi
call   1060 <srand@plt>
mov    $0xd,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10a0 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
movslq %eax,%rbp
movzbl 0x10(%rsp,%rbp,1),%r14d
xor    %eax,%eax
call   10a0 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
cltq
movzbl 0x10(%rsp,%rax,1),%ecx
mov    %cl,0x10(%rsp,%rbp,1)
mov    %r14b,0x10(%rsp,%rax,1)
add    $0xffffffff,%ebx
jne    11d0 <main+0x50>
mov    %rsp,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
lea    0xdce(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xded(%rip),%rdi
lea    0x50(%rsp),%rbp
mov    %rbp,%rsi
call   1080 <scanf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     12ea <main+0x16a>
lea    0xe69(%rip),%r14
mov    %rsp,%r15
lea    0xd8a(%rip),%r12
lea    0x10(%rsp),%rbx
lea    0xdb3(%rip),%r13
lea    0x50(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
call   1080 <scanf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    12b0 <main+0x130>
lea    0xe16(%rip),%rdi
call   1030 <puts@plt>
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    %rsp,%rdx
mov    %rbx,%rdi
mov    %rdx,%rsi
call   1090 <timersub@plt>
lea    0x40(%rsp),%rsi
mov    %rbx,%rdi
mov    %rbx,%rdx
call   1090 <timersub@plt>
mov    0x38(%rsp),%esi
mov    0x30(%rsp),%rdx
mov    0x8(%rsp),%ebx
mov    (%rsp),%rbp
lea    0xd18(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd58(%rip),%rdi
mov    %ebx,%esi
mov    %rbp,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i32 }
@__const.main.startAlph = [27 x i8] c"abcdefghijklmnopqrstuvwxyz\00"
@.str = [53 x i8] c"Type the following string (followed by <enter>):\0A%s\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [11 x i8] c"\0ACorrect!\0A\00"
@.str.3 = [24 x i8] c"\0AIncorrect. Try again.\0A\00"
@.str.4 = [78 x i8] c"It took you %d seconds (%ld microseconds) to type the whole thing correctly!\0A\00"
@.str.5 = [79 x i8] c"It took you %d seconds (%ld microseconds) to type it correctly the last time!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [27 x i8]
%7 = alloca i8
%8 = alloca i8
%9 = alloca i32
%10 = alloca i32
%11 = alloca [27 x i8]
%12 = alloca %struct.timeval
%13 = alloca %struct.timeval
%14 = alloca %struct.timeval
%15 = alloca i32
%16 = alloca i32
%17 = alloca i64
%18 = alloca i32
%19 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%20 = bitcast [27 x i8]* %6 to i8*
%21 = call i32 @gettimeofday(%struct.timeval* %12, i32* null)
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 0
%23 = load i64, i64* %22
%24 = call i32 @srand(i64 %23)
store i32 0, i32* %15
br label %25
25: ; preds = %47, %2
%26 = load i32, i32* %15
%27 = icmp slt i32 %26, 13
br i1 %27, label %28, label %50
28: ; preds = %25
%29 = call i32 (...) @rand()
%30 = srem i32 %29, 26
store i32 %30, i32* %9
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [27 x i8], [27 x i8]* %6, i64 0, i64 %31
%33 = load i8, i8* %32
store i8 %33, i8* %7
%34 = call i32 (...) @rand()
%35 = srem i32 %34, 26
store i32 %35, i32* %10
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [27 x i8], [27 x i8]* %6, i64 0, i64 %36
%38 = load i8, i8* %37
store i8 %38, i8* %8
%39 = load i8, i8* %8
%40 = load i32, i32* %9
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [27 x i8], [27 x i8]* %6, i64 0, i64 %41
store i8 %39, i8* %42
%43 = load i8, i8* %7
%44 = load i32, i32* %10
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [27 x i8], [27 x i8]* %6, i64 0, i64 %45
store i8 %43, i8* %46
br label %47
47: ; preds = %28
%48 = load i32, i32* %15
%49 = add nsw i32 %48, 1
store i32 %49, i32* %15
br label %25
50: ; preds = %25
br label %51
51: ; preds = %65, %50
%52 = call i32 @gettimeofday(%struct.timeval* %13, i32* null)
%53 = getelementptr inbounds [27 x i8], [27 x i8]* %6, i64 0, i64 0
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i8* %53)
%55 = getelementptr inbounds [27 x i8], [27 x i8]* %11, i64 0, i64 0
%56 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %55)
%57 = getelementptr inbounds [27 x i8], [27 x i8]* %6, i64 0, i64 0
%58 = getelementptr inbounds [27 x i8], [27 x i8]* %11, i64 0, i64 0
%59 = call i64 @strcmp(i8* %57, i8* %58)
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %51
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %66
63: ; preds = %51
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %65
65: ; preds = %63
br i1 true, label %51, label %66
66: ; preds = %65, %61
%67 = call i32 @gettimeofday(%struct.timeval* %14, i32* null)
%68 = call i32 @timersub(%struct.timeval* %14, %struct.timeval* %13, %struct.timeval* %13)
%69 = call i32 @timersub(%struct.timeval* %14, %struct.timeval* %12, %struct.timeval* %14)
%70 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 1
%71 = load i32, i32* %70
store i32 %71, i32* %16
%72 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 0
%73 = load i64, i64* %72
store i64 %73, i64* %17
%74 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 1
%75 = load i32, i32* %74
store i32 %75, i32* %18
%76 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 0
%77 = load i64, i64* %76
store i64 %77, i64* %19
%78 = load i32, i32* %16
%79 = load i64, i64* %17
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.4, i64 0, i64 0), i32 %78, i64 %79)
%81 = load i32, i32* %18
%82 = load i64, i64* %19
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.5, i64 0, i64 0), i32 %81, i64 %82)
%84 = load i32, i32* %3
ret i32 %84
}

LLVM IR (-O2):
%struct.timeval = type { i64, i32 }
@__const.main.startAlph = [27 x i8] c"abcdefghijklmnopqrstuvwxyz\00"
@.str = [53 x i8] c"Type the following string (followed by <enter>):\0A%s\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.4 = [78 x i8] c"It took you %d seconds (%ld microseconds) to type the whole thing correctly!\0A\00"
@.str.5 = [79 x i8] c"It took you %d seconds (%ld microseconds) to type it correctly the last time!\0A\00"
@str = [23 x i8] c"\0AIncorrect. Try again.\00"
@str.6 = [10 x i8] c"\0ACorrect!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [27 x i8]
%4 = alloca [27 x i8]
%5 = alloca %struct.timeval
%6 = alloca %struct.timeval
%7 = alloca %struct.timeval
%8 = getelementptr inbounds [27 x i8], [27 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [27 x i8], [27 x i8]* %4, i64 0, i64 0
%10 = bitcast %struct.timeval* %5 to i8*
%11 = bitcast %struct.timeval* %6 to i8*
%12 = bitcast %struct.timeval* %7 to i8*
%13 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 0
%15 = load i64, i64* %14
%16 = tail call i32 @srand(i64 %15)
br label %23
17: ; preds = %23
%18 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i8* %8)
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%21 = call i64 @strcmp(i8* %8, i8* %9)
%22 = icmp eq i64 %21, 0
br i1 %22, label %37, label %52
23: ; preds = %2, %23
%24 = phi i32 [ 0, %2 ], [ %35, %23 ]
%25 = tail call i32 (...) @rand()
%26 = srem i32 %25, 26
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [27 x i8], [27 x i8]* %3, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = tail call i32 (...) @rand()
%31 = srem i32 %30, 26
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [27 x i8], [27 x i8]* %3, i64 0, i64 %32
%34 = load i8, i8* %33
store i8 %34, i8* %28
store i8 %29, i8* %33
%35 = add nuw nsw i32 %24, 1
%36 = icmp eq i32 %35, 13
br i1 %36, label %17, label %23
37: ; preds = %52, %17
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.6, i64 0, i64 0))
%39 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%40 = call i32 @timersub(%struct.timeval* %7, %struct.timeval* %6, %struct.timeval* %6)
%41 = call i32 @timersub(%struct.timeval* %7, %struct.timeval* %5, %struct.timeval* %7)
%42 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i64 0, i32 1
%43 = load i32, i32* %42
%44 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i64 0, i32 0
%45 = load i64, i64* %44
%46 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 1
%47 = load i32, i32* %46
%48 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 0
%49 = load i64, i64* %48
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @.str.4, i64 0, i64 0), i32 %43, i64 %45)
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([79 x i8], [79 x i8]* @.str.5, i64 0, i64 0), i32 %47, i64 %49)
ret i32 0
52: ; preds = %17, %52
%53 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%54 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i8* %8)
%56 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%57 = call i64 @strcmp(i8* %8, i8* %9)
%58 = icmp eq i64 %57, 0
br i1 %58, label %37, label %52
}