#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 EXIT_SUCCESS;
int /*<<< orphan*/ printCode(char *, char *, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ translateCode(char *, char *, char *, char *);
int main(void) {
  char question[1], scanString[25], code[25], warehouse[25], product[25],
      qualifier[25];
  int scanCustom;
  do {
    printf("Do you want to scan a product code? If no, we'll use an example "
           "(y/n) ");
    scanf(" %c", question);
    scanCustom = (*question == 'y');
  } while (strlen(question) == 0);
  if (scanCustom) {
    do {
      printf("Input custom barcode (max length is: %d): ", 25);
      scanf("%s", scanString);
    } while (!strlen(scanString));
    strcpy(code, scanString);
  } else {
    strcpy(code, "ATL1203S14");
  }
  translateCode(code, warehouse, product, qualifier);
  printCode(code, warehouse, product, qualifier);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x5(%rbp),%rsi
lea    0xebc(%rip),%rdi
call   1070 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x79,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0xa4(%rbp)
lea    -0x5(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%rax
je     1172 <main+0x12>
cmpl   $0x0,-0xa4(%rbp)
je     1219 <main+0xb9>
jmp    11ca <main+0x6a>
lea    0xe7a(%rip),%rdi
mov    $0x19,%esi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xe8e(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11ca <main+0x6a>
lea    -0x40(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <strcpy@plt>
jmp    1229 <main+0xc9>
lea    -0x40(%rbp),%rdi
lea    0xe55(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x40(%rbp),%rdi
lea    -0x60(%rbp),%rsi
lea    -0x80(%rbp),%rdx
lea    -0xa0(%rbp),%rcx
call   1080 <translateCode@plt>
lea    -0x40(%rbp),%rdi
lea    -0x60(%rbp),%rsi
lea    -0x80(%rbp),%rdx
lea    -0xa0(%rbp),%rcx
call   1030 <printCode@plt>
mov    0x2d80(%rip),%rax
mov    (%rax),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xb8,%rsp
lea    0xe9b(%rip),%r14
lea    0xedb(%rip),%r15
lea    0xf(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
movzbl 0xf(%rsp),%eax
test   %al,%al
je     1180 <main+0x30>
cmp    $0x79,%al
jne    11ed <main+0x9d>
lea    0xea2(%rip),%r14
lea    0xec6(%rip),%r15
lea    0x30(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    $0x19,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
cmpb   $0x0,0x30(%rsp)
je     11c0 <main+0x70>
lea    0x10(%rsp),%rdi
lea    0x30(%rsp),%rsi
jmp    11f9 <main+0xa9>
lea    0xe85(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1040 <strcpy@plt>
lea    0x10(%rsp),%rbx
lea    0x90(%rsp),%r14
lea    0x70(%rsp),%r15
lea    0x50(%rsp),%r12
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
call   1070 <translateCode@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
call   1030 <printCode@plt>
mov    0x2da2(%rip),%rax
mov    (%rax),%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [71 x i8] c"Do you want to scan a product code? If no, we'll use an example (y/n) \00"
@.str.1 = [4 x i8] c" %c\00"
@.str.2 = [43 x i8] c"Input custom barcode (max length is: %d): \00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [11 x i8] c"ATL1203S14\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [1 x i8]
%3 = alloca [25 x i8]
%4 = alloca [25 x i8]
%5 = alloca [25 x i8]
%6 = alloca [25 x i8]
%7 = alloca [25 x i8]
%8 = alloca i32
store i32 0, i32* %1
br label %9
9: ; preds = %18, %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds [1 x i8], [1 x i8]* %2, i64 0, i64 0
%12 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [1 x i8], [1 x i8]* %2, i64 0, i64 0
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 121
%17 = zext i1 %16 to i32
store i32 %17, i32* %8
br label %18
18: ; preds = %9
%19 = getelementptr inbounds [1 x i8], [1 x i8]* %2, i64 0, i64 0
%20 = call i64 @strlen(i8* %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %9, label %22
22: ; preds = %18
%23 = load i32, i32* %8
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %39
25: ; preds = %22
br label %26
26: ; preds = %30, %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 25)
%28 = getelementptr inbounds [25 x i8], [25 x i8]* %3, i64 0, i64 0
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %28)
br label %30
30: ; preds = %26
%31 = getelementptr inbounds [25 x i8], [25 x i8]* %3, i64 0, i64 0
%32 = call i64 @strlen(i8* %31)
%33 = icmp ne i64 %32, 0
%34 = xor i1 %33, true
br i1 %34, label %26, label %35
35: ; preds = %30
%36 = getelementptr inbounds [25 x i8], [25 x i8]* %4, i64 0, i64 0
%37 = getelementptr inbounds [25 x i8], [25 x i8]* %3, i64 0, i64 0
%38 = call i32 @strcpy(i8* %36, i8* %37)
br label %42
39: ; preds = %22
%40 = getelementptr inbounds [25 x i8], [25 x i8]* %4, i64 0, i64 0
%41 = call i32 @strcpy(i8* %40, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %42
42: ; preds = %39, %35
%43 = getelementptr inbounds [25 x i8], [25 x i8]* %4, i64 0, i64 0
%44 = getelementptr inbounds [25 x i8], [25 x i8]* %5, i64 0, i64 0
%45 = getelementptr inbounds [25 x i8], [25 x i8]* %6, i64 0, i64 0
%46 = getelementptr inbounds [25 x i8], [25 x i8]* %7, i64 0, i64 0
%47 = call i32 @translateCode(i8* %43, i8* %44, i8* %45, i8* %46)
%48 = getelementptr inbounds [25 x i8], [25 x i8]* %4, i64 0, i64 0
%49 = getelementptr inbounds [25 x i8], [25 x i8]* %5, i64 0, i64 0
%50 = getelementptr inbounds [25 x i8], [25 x i8]* %6, i64 0, i64 0
%51 = getelementptr inbounds [25 x i8], [25 x i8]* %7, i64 0, i64 0
%52 = call i32 @printCode(i8* %48, i8* %49, i8* %50, i8* %51)
%53 = load i32, i32* @EXIT_SUCCESS
ret i32 %53
}

LLVM IR (-O2):
@.str = [71 x i8] c"Do you want to scan a product code? If no, we'll use an example (y/n) \00"
@.str.1 = [4 x i8] c" %c\00"
@.str.2 = [43 x i8] c"Input custom barcode (max length is: %d): \00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [11 x i8] c"ATL1203S14\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [1 x i8]
%2 = alloca [25 x i8]
%3 = alloca [25 x i8]
%4 = alloca [25 x i8]
%5 = alloca [25 x i8]
%6 = alloca [25 x i8]
%7 = getelementptr inbounds [1 x i8], [1 x i8]* %1, i64 0, i64 0
%8 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [25 x i8], [25 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [25 x i8], [25 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [25 x i8], [25 x i8]* %5, i64 0, i64 0
%12 = getelementptr inbounds [25 x i8], [25 x i8]* %6, i64 0, i64 0
br label %13
13: ; preds = %13, %0
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%16 = load i8, i8* %7
switch i8 %16, label %24 [
i8 0, label %13
i8 121, label %17
]
17: ; preds = %13, %17
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 25)
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %8)
%20 = load i8, i8* %8
%21 = icmp eq i8 %20, 0
br i1 %21, label %17, label %22
22: ; preds = %17
%23 = call i32 @strcpy(i8* %9, i8* %8)
br label %26
24: ; preds = %13
%25 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %26
26: ; preds = %24, %22
%27 = call i32 @translateCode(i8* %9, i8* %10, i8* %11, i8* %12)
%28 = call i32 @printCode(i8* %9, i8* %10, i8* %11, i8* %12)
%29 = load i32, i32* @EXIT_SUCCESS
ret i32 %29
}