#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 */
scalar_t__ badhand(char *);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ srand(int);
int time(int /*<<< orphan*/ *);
void genhand(char hand[]) {
  int i = 0;
  srand(rand() * time(NULL));
  if (1)
    printf("enters genhand &seeds\n");
  printf("Here are %d letters for you to play with:\n\n", 7);
  for (i = 0; i < 7; i++) {
    hand[i] = rand() % 26 + 'A';
    printf("%c ", hand[i]);
  }
  if (badhand(hand)) {
    for (i = 0; i < 7; i++)
      printf("\b \b\b \b");
    printf("OOF, HAD A BAD HAND THERE. SORRY.\n");
    genhand(hand);
  }
  printf("\n\n");
  if (1)
    printf("finishes genhand\n");
}


x86 assembly (clang, -O0):
<genhand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
mov    %eax,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    -0x10(%rbp),%edi
imul   %eax,%edi
call   1050 <srand@plt>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe71(%rip),%rdi
mov    $0x7,%esi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x7,-0xc(%rbp)
jge    1208 <genhand+0xa8>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x1a,%ecx
cltd
idiv   %ecx
add    $0x41,%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11b9 <genhand+0x59>
mov    -0x8(%rbp),%rdi
call   1070 <badhand@plt>
cmp    $0x0,%rax
je     125f <genhand+0xff>
movl   $0x0,-0xc(%rbp)
cmpl   $0x7,-0xc(%rbp)
jge    1248 <genhand+0xe8>
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1222 <genhand+0xc2>
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <genhand@plt>
lea    0xdda(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<genhand>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
xor    %eax,%eax
call   1090 <rand@plt>
mov    %eax,%ebx
xor    %edi,%edi
call   1070 <time@plt>
imul   %eax,%ebx
mov    %ebx,%edi
call   1060 <srand@plt>
lea    0xe9e(%rip),%rdi
call   1030 <puts@plt>
lea    0xe5b(%rip),%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1090 <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
add    $0x41,%al
mov    %al,(%r15)
movzbl %al,%esi
lea    0xe45(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1090 <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
add    $0x41,%al
mov    %al,0x1(%r15)
movzbl %al,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1090 <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
add    $0x41,%al
mov    %al,0x2(%r15)
movzbl %al,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1090 <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
add    $0x41,%al
mov    %al,0x3(%r15)
movzbl %al,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1090 <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
add    $0x41,%al
mov    %al,0x4(%r15)
movzbl %al,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1090 <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
add    $0x41,%al
mov    %al,0x5(%r15)
movzbl %al,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1090 <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
add    $0x41,%al
mov    %al,0x6(%r15)
movzbl %al,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
call   1080 <badhand@plt>
test   %rax,%rax
je     13bb <genhand+0x24b>
lea    0xccf(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xcb0(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1040 <genhand@plt>
lea    0xc68(%rip),%rdi
call   1030 <puts@plt>
lea    0xc7f(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"enters genhand &seeds\0A\00"
@.str.1 = [44 x i8] c"Here are %d letters for you to play with:\0A\0A\00"
@.str.2 = [4 x i8] c"%c \00"
@.str.3 = [7 x i8] c"\08 \08\08 \08\00"
@.str.4 = [35 x i8] c"OOF, HAD A BAD HAND THERE. SORRY.\0A\00"
@.str.5 = [3 x i8] c"\0A\0A\00"
@.str.6 = [18 x i8] c"finishes genhand\0A\00"
define void @genhand(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
%4 = call i32 (...) @rand()
%5 = call i32 @time(i32* null)
%6 = mul nsw i32 %4, %5
%7 = call i32 @srand(i32 %6)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i32 7)
store i32 0, i32* %3
br label %10
10: ; preds = %29, %1
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 7
br i1 %12, label %13, label %32
13: ; preds = %10
%14 = call i32 (...) @rand()
%15 = srem i32 %14, 26
%16 = add nsw i32 %15, 65
%17 = trunc i32 %16 to i8
%18 = load i8*, i8** %2
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
store i8 %17, i8* %21
%22 = load i8*, i8** %2
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %13
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %10
32: ; preds = %10
%33 = load i8*, i8** %2
%34 = call i64 @badhand(i8* %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %48
36: ; preds = %32
store i32 0, i32* %3
br label %37
37: ; preds = %42, %36
%38 = load i32, i32* %3
%39 = icmp slt i32 %38, 7
br i1 %39, label %40, label %45
40: ; preds = %37
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %42
42: ; preds = %40
%43 = load i32, i32* %3
%44 = add nsw i32 %43, 1
store i32 %44, i32* %3
br label %37
45: ; preds = %37
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%47 = load i8*, i8** %2
br label %48
48: ; preds = %45, %32
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [44 x i8] c"Here are %d letters for you to play with:\0A\0A\00"
@.str.2 = [4 x i8] c"%c \00"
@.str.3 = [7 x i8] c"\08 \08\08 \08\00"
@str = [22 x i8] c"enters genhand &seeds\00"
@str.7 = [2 x i8] c"\0A\00"
@str.8 = [17 x i8] c"finishes genhand\00"
@str.9 = [34 x i8] c"OOF, HAD A BAD HAND THERE. SORRY.\00"
define void @genhand(i8* %0) {
%2 = tail call i32 (...) @rand()
%3 = tail call i32 @time(i32* null)
%4 = mul nsw i32 %3, %2
%5 = tail call i32 @srand(i32 %4)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i32 7)
%8 = tail call i32 (...) @rand()
%9 = srem i32 %8, 26
%10 = trunc i32 %9 to i8
%11 = add nsw i8 %10, 65
store i8 %11, i8* %0
%12 = zext i8 %11 to i32
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = tail call i32 (...) @rand()
%15 = srem i32 %14, 26
%16 = trunc i32 %15 to i8
%17 = add nsw i8 %16, 65
%18 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %17, i8* %18
%19 = zext i8 %17 to i32
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = tail call i32 (...) @rand()
%22 = srem i32 %21, 26
%23 = trunc i32 %22 to i8
%24 = add nsw i8 %23, 65
%25 = getelementptr inbounds i8, i8* %0, i64 2
store i8 %24, i8* %25
%26 = zext i8 %24 to i32
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = tail call i32 (...) @rand()
%29 = srem i32 %28, 26
%30 = trunc i32 %29 to i8
%31 = add nsw i8 %30, 65
%32 = getelementptr inbounds i8, i8* %0, i64 3
store i8 %31, i8* %32
%33 = zext i8 %31 to i32
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = tail call i32 (...) @rand()
%36 = srem i32 %35, 26
%37 = trunc i32 %36 to i8
%38 = add nsw i8 %37, 65
%39 = getelementptr inbounds i8, i8* %0, i64 4
store i8 %38, i8* %39
%40 = zext i8 %38 to i32
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %40)
%42 = tail call i32 (...) @rand()
%43 = srem i32 %42, 26
%44 = trunc i32 %43 to i8
%45 = add nsw i8 %44, 65
%46 = getelementptr inbounds i8, i8* %0, i64 5
store i8 %45, i8* %46
%47 = zext i8 %45 to i32
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %47)
%49 = tail call i32 (...) @rand()
%50 = srem i32 %49, 26
%51 = trunc i32 %50 to i8
%52 = add nsw i8 %51, 65
%53 = getelementptr inbounds i8, i8* %0, i64 6
store i8 %52, i8* %53
%54 = zext i8 %52 to i32
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %54)
%56 = tail call i64 @badhand(i8* %0)
%57 = icmp eq i64 %56, 0
br i1 %57, label %67, label %58
58: ; preds = %1
%59 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%60 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%61 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%62 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%63 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%64 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%65 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%66 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.9, i64 0, i64 0))
tail call void @genhand(i8* %0)
br label %67
67: ; preds = %58, %1
%68 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.7, i64 0, i64 0))
%69 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.8, i64 0, i64 0))
ret void
}