#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 check_userInput(char *);
int /*<<< orphan*/ free(char *);
char *genNumber_hexStr();
char *malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main(int argc, char **argv) {
  char *msgPrompt = genNumber_hexStr();
  char *strOutput0 = "Enter on device: ";
  char *strOutput1 = "\nDevice response: ";
  int tmpLen = strlen(strOutput0) + strlen(strOutput1) + strlen(msgPrompt) + 1;
  char msgPromptInstr[tmpLen];
  sprintf(msgPromptInstr, "%s%s%s", strOutput0, msgPrompt, strOutput1);
  free(msgPrompt);
  char *userInputt = malloc(14);
  strcpy(userInputt, "QB5jjpsmzKFB\0");
  int strCompared = check_userInput(userInputt);
  printf("\nEOF\n");
  if (strCompared == 0) {
    return 0;
  } else {
    return 1;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
call   1050 <genNumber_hexStr@plt>
mov    %rax,-0x18(%rbp)
lea    0xe58(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xe5f(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x58(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x58(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x54(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%edx
mov    -0x54(%rbp),%eax
mov    %eax,%ecx
mov    %edx,%eax
lea    0x1(%rax,%rcx,1),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,%rsp
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x28(%rbp),%r8
lea    0xe01(%rip),%rsi
call   10a0 <sprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    $0xe,%edi
call   1090 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
lea    0xde7(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x48(%rbp),%rdi
call   1080 <check_userInput@plt>
mov    %eax,-0x4c(%rbp)
lea    0xdc9(%rip),%rdi
call   1070 <printf@plt>
cmpl   $0x0,-0x4c(%rbp)
jne    1285 <main+0x105>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x50(%rbp)
jmp    1293 <main+0x113>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x50(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1060 <genNumber_hexStr@plt>
mov    %rax,%r13
lea    0xe61(%rip),%r14
mov    %r14,%rdi
call   1070 <strlen@plt>
mov    %eax,%r12d
lea    0xe61(%rip),%r15
mov    %r15,%rdi
call   1070 <strlen@plt>
mov    %eax,%ebx
mov    %r13,%rdi
call   1070 <strlen@plt>
add    %r12d,%ebx
add    %ebx,%eax
add    $0x1,%eax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rdi
sub    %rax,%rdi
mov    %rdi,%rsp
lea    0xe42(%rip),%rsi
mov    %r14,%rdx
mov    %r13,%rcx
mov    %r15,%r8
call   10a0 <sprintf@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    $0xe,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
lea    0xe24(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1080 <check_userInput@plt>
mov    %eax,%ebx
lea    0xe06(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
test   %ebx,%ebx
setne  %al
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Enter on device: \00"
@.str.1 = [19 x i8] c"\0ADevice response: \00"
@.str.2 = [7 x i8] c"%s%s%s\00"
@.str.3 = [14 x i8] c"QB5jjpsmzKFB\00\00"
@.str.4 = [6 x i8] c"\0AEOF\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = call i8* (...) @genNumber_hexStr()
store i8* %15, i8** %6
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8** %7
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8** %8
%16 = load i8*, i8** %7
%17 = call i32 @strlen(i8* %16)
%18 = load i8*, i8** %8
%19 = call i32 @strlen(i8* %18)
%20 = add nsw i32 %17, %19
%21 = load i8*, i8** %6
%22 = call i32 @strlen(i8* %21)
%23 = add nsw i32 %20, %22
%24 = add nsw i32 %23, 1
store i32 %24, i32* %9
%25 = load i32, i32* %9
%26 = zext i32 %25 to i64
%27 = call i8* @llvm.stacksave()
store i8* %27, i8** %10
%28 = alloca i8, i64 %26
store i64 %26, i64* %11
%29 = load i8*, i8** %7
%30 = load i8*, i8** %6
%31 = load i8*, i8** %8
%32 = call i32 @sprintf(i8* %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %29, i8* %30, i8* %31)
%33 = load i8*, i8** %6
%34 = call i32 @free(i8* %33)
%35 = call i8* @malloc(i32 14)
store i8* %35, i8** %12
%36 = load i8*, i8** %12
%37 = call i32 @strcpy(i8* %36, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%38 = load i8*, i8** %12
%39 = call i32 @check_userInput(i8* %38)
store i32 %39, i32* %13
%40 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%41 = load i32, i32* %13
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %2
store i32 0, i32* %3
store i32 1, i32* %14
br label %45
44: ; preds = %2
store i32 1, i32* %3
store i32 1, i32* %14
br label %45
45: ; preds = %44, %43
%46 = load i8*, i8** %10
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@.str = [18 x i8] c"Enter on device: \00"
@.str.1 = [19 x i8] c"\0ADevice response: \00"
@.str.2 = [7 x i8] c"%s%s%s\00"
@.str.3 = [14 x i8] c"QB5jjpsmzKFB\00\00"
@str = [5 x i8] c"\0AEOF\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i8* (...) @genNumber_hexStr()
%4 = tail call i32 @strlen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @strlen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @strlen(i8* %3)
%7 = add i32 %4, 1
%8 = add i32 %7, %5
%9 = add i32 %8, %6
%10 = zext i32 %9 to i64
%11 = alloca i8, i64 %10
%12 = call i32 @sprintf(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %3, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i32 @free(i8* %3)
%14 = tail call dereferenceable_or_null(14) i8* @malloc(i32 14)
%15 = tail call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%16 = tail call i32 @check_userInput(i8* %14)
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
%18 = icmp ne i32 %16, 0
%19 = zext i1 %18 to i32
ret i32 %19
}