#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 readField(int, char **, char);
int readArgs(int sd, char *argv[], size_t n) {
  size_t i = 0;
  int ret = 1;
  while (i < n && ret > 0) {
    ret = readField(sd, &argv[i], ':');
    i++;
  }
  return ret;
}


x86 assembly (clang, -O0):
<readArgs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x20(%rbp),%rcx
xor    %eax,%eax
cmp    -0x18(%rbp),%rcx
mov    %al,-0x25(%rbp)
jae    114f <readArgs+0x3f>
cmpl   $0x0,-0x24(%rbp)
setg   %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    115f <readArgs+0x4f>
jmp    118f <readArgs+0x7f>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
mov    $0x3a,%edx
call   1030 <readField@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1132 <readArgs+0x22>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readArgs>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %rdx,%rdx
je     1153 <readArgs+0x43>
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%r15d
mov    $0x1,%ebp
nopw   0x0(%rax,%rax,1)
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x3a,%edx
call   1030 <readField@plt>
cmp    %r14,%rbp
jae    1158 <readArgs+0x48>
add    $0x1,%rbp
add    $0x8,%rbx
test   %eax,%eax
jg     1130 <readArgs+0x20>
jmp    1158 <readArgs+0x48>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @readArgs(i32 %0, i8** %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 %2, i64* %6
store i64 0, i64* %7
store i32 1, i32* %8
br label %9
9: ; preds = %18, %3
%10 = load i64, i64* %7
%11 = load i64, i64* %6
%12 = icmp ult i64 %10, %11
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = load i32, i32* %8
%15 = icmp sgt i32 %14, 0
br label %16
16: ; preds = %13, %9
%17 = phi i1 [ false, %9 ], [ %15, %13 ]
br i1 %17, label %18, label %26
18: ; preds = %16
%19 = load i32, i32* %4
%20 = load i8**, i8*** %5
%21 = load i64, i64* %7
%22 = getelementptr inbounds i8*, i8** %20, i64 %21
%23 = call i32 @readField(i32 %19, i8** %22, i8 signext 58)
store i32 %23, i32* %8
%24 = load i64, i64* %7
%25 = add i64 %24, 1
store i64 %25, i64* %7
br label %9
26: ; preds = %16
%27 = load i32, i32* %8
ret i32 %27
}

LLVM IR (-O2):
define i32 @readArgs(i32 %0, i8** %1, i64 %2) {
%4 = icmp eq i64 %2, 0
br i1 %4, label %13, label %5
5: ; preds = %3, %5
%6 = phi i64 [ %9, %5 ], [ 0, %3 ]
%7 = getelementptr inbounds i8*, i8** %1, i64 %6
%8 = tail call i32 @readField(i32 %0, i8** %7, i8 signext 58)
%9 = add nuw i64 %6, 1
%10 = icmp ult i64 %9, %2
%11 = icmp sgt i32 %8, 0
%12 = select i1 %10, i1 %11, i1 false
br i1 %12, label %5, label %13
13: ; preds = %5, %3
%14 = phi i32 [ 1, %3 ], [ %8, %5 ]
ret i32 %14
}