#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 */
typedef int /*<<< orphan*/ text;

/* Variables and functions */
scalar_t__ anchorGetNext(int, unsigned int *, char *, int, unsigned int *,
                         unsigned int *, char *);
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int LotNr;
  unsigned int DocID;
  char text[50];
  unsigned int radress;
  unsigned int rsize;
  char *subname;
  if (argc < 3) {
    printf("Usage: ./anchorreadnew lotnr subname\n\n");
    exit(1);
  }
  LotNr = atoi(argv[1]);
  subname = argv[2];
  while (anchorGetNext(LotNr, &DocID, text, sizeof(text), &radress, &rsize,
                       subname)) {
    printf("DocID %i, text: %s\n", DocID, text);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1178 <main+0x38>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x60(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x50(%rbp),%rdx
mov    -0x60(%rbp),%rax
lea    -0x18(%rbp),%rsi
mov    $0x32,%ecx
lea    -0x54(%rbp),%r8
lea    -0x58(%rbp),%r9
mov    %rax,(%rsp)
call   1040 <anchorGetNext@plt>
cmp    $0x0,%rax
je     11dd <main+0x9d>
mov    -0x18(%rbp),%esi
lea    -0x50(%rbp),%rdx
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1194 <main+0x54>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
cmp    $0x2,%edi
jle    1207 <main+0xb7>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%r14
mov    %r14,(%rsp)
lea    0x14(%rsp),%rsi
lea    0x20(%rsp),%rdx
lea    0x1c(%rsp),%r8
lea    0x18(%rsp),%r9
mov    %eax,%edi
mov    $0x32,%ecx
call   1050 <anchorGetNext@plt>
test   %rax,%rax
je     11f6 <main+0xa6>
lea    0x20(%rsp),%rbx
lea    0x14(%rsp),%r15
lea    0x1c(%rsp),%r12
lea    0x18(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
mov    0x14(%rsp),%esi
lea    0xe35(%rip),%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,(%rsp)
mov    %ebp,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    $0x32,%ecx
mov    %r12,%r8
mov    %r13,%r9
call   1050 <anchorGetNext@plt>
test   %rax,%rax
jne    11c0 <main+0x70>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe06(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [39 x i8] c"Usage: ./anchorreadnew lotnr subname\0A\0A\00"
@.str.1 = [20 x i8] c"DocID %i, text: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [50 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 3
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %6
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
store i8* %24, i8** %11
br label %25
25: ; preds = %31, %17
%26 = load i32, i32* %6
%27 = getelementptr inbounds [50 x i8], [50 x i8]* %8, i64 0, i64 0
%28 = load i8*, i8** %11
%29 = call i64 @anchorGetNext(i32 %26, i32* %7, i8* %27, i32 50, i32* %9, i32* %10, i8* %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %25
%32 = load i32, i32* %7
%33 = getelementptr inbounds [50 x i8], [50 x i8]* %8, i64 0, i64 0
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %32, i8* %33)
br label %25
35: ; preds = %25
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@.str.1 = [20 x i8] c"DocID %i, text: %s\0A\00"
@str = [38 x i8] c"Usage: ./anchorreadnew lotnr subname\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [50 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %3 to i8*
%8 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%9 = bitcast i32* %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = icmp slt i32 %0, 3
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i32 @atoi(i8* %17)
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
%21 = call i64 @anchorGetNext(i32 %18, i32* %3, i8* %8, i32 50, i32* %5, i32* %6, i8* %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %28, label %23
23: ; preds = %15, %23
%24 = load i32, i32* %3
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %24, i8* %8)
%26 = call i64 @anchorGetNext(i32 %18, i32* %3, i8* %8, i32 50, i32* %5, i32* %6, i8* %20)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %23
28: ; preds = %23, %15
ret i32 0
}