#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 /*<<< orphan*/ clear();
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, long *, char *);
void inputBarcode(const char *prompt, long int barcode[], int i) {
  char endInput;
  int result = 0;
  int read;
  do {
    printf("%s", prompt);
    read = scanf("%ld%c", &barcode[i], &endInput);
    if (read != 2) {
      printf("ERROR! Try Again!\n");
      result = 0;
      clear();
    } else if (endInput != '\n') {
      printf("ERROR! Try Again!\n");
      result = 0;
      clear();
    } else if (barcode[i] == 0)
      result = 1;
    else if (barcode[i] < 1000000000 || barcode[i] > 9999999999) {
      printf("ERROR! Try Again!\n");
      result = 0;
    } else
      result = 1;
  } while (result == 0);
}


x86 assembly (clang, -O0):
<inputBarcode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
lea    0xe91(%rip),%rdi
lea    -0x15(%rbp),%rdx
call   1040 <scanf@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x2,-0x20(%rbp)
je     11a9 <inputBarcode+0x79>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    $0x0,%al
call   1050 <clear@plt>
jmp    1258 <inputBarcode+0x128>
movsbl -0x15(%rbp),%eax
cmp    $0xa,%eax
je     11d7 <inputBarcode+0xa7>
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    $0x0,%al
call   1050 <clear@plt>
jmp    1253 <inputBarcode+0x123>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    11f6 <inputBarcode+0xc6>
movl   $0x1,-0x1c(%rbp)
jmp    124e <inputBarcode+0x11e>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpq   $0x3b9aca00,(%rax,%rcx,8)
3b
jl     1228 <inputBarcode+0xf8>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movabs $0x2540be3ff,%rdx
cmp    %rdx,(%rax,%rcx,8)
jle    1242 <inputBarcode+0x112>
lea    0xdda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
jmp    1249 <inputBarcode+0x119>
movl   $0x1,-0x1c(%rbp)
jmp    124e <inputBarcode+0x11e>
jmp    1253 <inputBarcode+0x123>
jmp    1258 <inputBarcode+0x128>
jmp    125d <inputBarcode+0x12d>
cmpl   $0x0,-0x1c(%rbp)
je     114a <inputBarcode+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inputBarcode>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
movabs $0xfffffffdabf41c00,%rcx
ff ff ff
movslq %edx,%rax
lea    (%rsi,%rax,8),%rbx
lea    0xe97(%rip),%r15
lea    0xe93(%rip),%r12
lea    0xf(%rsp),%r13
lea    0x3b9aca00(%rcx),%rax
mov    %rax,0x10(%rsp)
lea    0xe81(%rip),%rbp
jmp    119f <inputBarcode+0x5f>
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <clear@plt>
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1050 <scanf@plt>
cmp    $0x2,%eax
jne    1190 <inputBarcode+0x50>
cmpb   $0xa,0xf(%rsp)
jne    1190 <inputBarcode+0x50>
mov    (%rbx),%rax
test   %rax,%rax
je     11ec <inputBarcode+0xac>
movabs $0xfffffffdabf41c00,%rcx
ff ff ff
add    %rcx,%rax
cmp    0x10(%rsp),%rax
jae    11ec <inputBarcode+0xac>
mov    %rbp,%rdi
call   1030 <puts@plt>
jmp    119f <inputBarcode+0x5f>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [6 x i8] c"%ld%c\00"
@.str.2 = [19 x i8] c"ERROR! Try Again!\0A\00"
define void @inputBarcode(i8* %0, i64* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i64*
%6 = alloca i32
%7 = alloca i8
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i64* %1, i64** %5
store i32 %2, i32* %6
store i32 0, i32* %8
br label %10
10: ; preds = %59, %3
%11 = load i8*, i8** %4
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = load i64*, i64** %5
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i64, i64* %13, i64 %15
%17 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64* %16, i8* %7)
store i32 %17, i32* %9
%18 = load i32, i32* %9
%19 = icmp ne i32 %18, 2
br i1 %19, label %20, label %23
20: ; preds = %10
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %8
%22 = call i32 (...) @clear()
br label %58
23: ; preds = %10
%24 = load i8, i8* %7
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 10
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %8
%29 = call i32 (...) @clear()
br label %57
30: ; preds = %23
%31 = load i64*, i64** %5
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i64, i64* %31, i64 %33
%35 = load i64, i64* %34
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %30
store i32 1, i32* %8
br label %56
38: ; preds = %30
%39 = load i64*, i64** %5
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i64, i64* %39, i64 %41
%43 = load i64, i64* %42
%44 = icmp slt i64 %43, 1000000000
br i1 %44, label %52, label %45
45: ; preds = %38
%46 = load i64*, i64** %5
%47 = load i32, i32* %6
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i64, i64* %46, i64 %48
%50 = load i64, i64* %49
%51 = icmp sgt i64 %50, 9999999999
br i1 %51, label %52, label %54
52: ; preds = %45, %38
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %8
br label %55
54: ; preds = %45
store i32 1, i32* %8
br label %55
55: ; preds = %54, %52
br label %56
56: ; preds = %55, %37
br label %57
57: ; preds = %56, %27
br label %58
58: ; preds = %57, %20
br label %59
59: ; preds = %58
%60 = load i32, i32* %8
%61 = icmp eq i32 %60, 0
br i1 %61, label %10, label %62
62: ; preds = %59
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [6 x i8] c"%ld%c\00"
@str.4 = [18 x i8] c"ERROR! Try Again!\00"
define void @inputBarcode(i8* %0, i64* %1, i32 %2) {
%4 = alloca i8
%5 = sext i32 %2 to i64
%6 = getelementptr inbounds i64, i64* %1, i64 %5
br label %7
7: ; preds = %14, %3
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
%9 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64* %6, i8* %4)
%10 = icmp eq i32 %9, 2
br i1 %10, label %15, label %11
11: ; preds = %7
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.4, i64 0, i64 0))
%13 = call i32 (...) @clear()
br label %14
14: ; preds = %11, %27, %18
br label %7
15: ; preds = %7
%16 = load i8, i8* %4
%17 = icmp eq i8 %16, 10
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.4, i64 0, i64 0))
%20 = call i32 (...) @clear()
br label %14
21: ; preds = %15
%22 = load i64, i64* %6
%23 = icmp ne i64 %22, 0
%24 = add i64 %22, -10000000000
%25 = icmp ult i64 %24, -9000000000
%26 = and i1 %23, %25
br i1 %26, label %27, label %29
27: ; preds = %21
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.4, i64 0, i64 0))
br label %14
29: ; preds = %21
ret void
}