#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 make_ia_object(int, char **, char **, int *);
scalar_t__ put32(char **, int *, int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ warn(char *, char *);
int /*<<< orphan*/ warnx(char *);
int make_binding_object(int argc, char **argv, char **bpp, int *lenp) {
  int argc_passed = 0, passed;
  if (argc == 0) {
    warnx("make_binding_object: command is too short");
    return (-1);
  }
  if (strcmp(argv[0], "IA") == 0) {
    if (put32(bpp, lenp, 2))
      goto fail;
    if ((passed = make_ia_object(argc - 1, argv + 1, bpp, lenp)) < 0) {
      return (-1);
    }
    argc_passed += passed;
  } else {
    warn("unknown binding type: %s", argv[0]);
    return (-1);
  }
  argc_passed++;
  return (argc_passed);
fail:
  warnx("make_binding_object: failed");
  return (-1);
}


x86 assembly (clang, -O0):
<make_binding_object>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1190 <make_binding_object+0x40>
lea    0xe81(%rip),%rdi
call   1050 <warnx@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1255 <make_binding_object+0x105>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe8c(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    120f <make_binding_object+0xbf>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x2,%edx
call   1070 <put32@plt>
cmp    $0x0,%rax
je     11ce <make_binding_object+0x7e>
jmp    1242 <make_binding_object+0xf2>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1030 <make_ia_object@plt>
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
jge    1201 <make_binding_object+0xb1>
movl   $0xffffffff,-0x4(%rbp)
jmp    1255 <make_binding_object+0x105>
mov    -0x28(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    122e <make_binding_object+0xde>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe10(%rip),%rdi
call   1040 <warn@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1255 <make_binding_object+0x105>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1255 <make_binding_object+0x105>
lea    0xdfd(%rip),%rdi
call   1050 <warnx@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_binding_object>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
je     118b <make_binding_object+0x3b>
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %edi,%ebp
mov    (%rsi),%rdi
lea    0xeba(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1194 <make_binding_object+0x44>
mov    (%rbx),%rsi
lea    0xea9(%rip),%rdi
call   1040 <warn@plt>
jmp    11b5 <make_binding_object+0x65>
lea    0xe6e(%rip),%rdi
jmp    11b0 <make_binding_object+0x60>
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x2,%edx
call   1070 <put32@plt>
test   %rax,%rax
je     11c5 <make_binding_object+0x75>
lea    0xe96(%rip),%rdi
call   1050 <warnx@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
add    $0xffffffff,%ebp
add    $0x8,%rbx
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1030 <make_ia_object@plt>
lea    0x1(%rax),%ecx
test   %eax,%eax
mov    $0xffffffff,%eax
cmovns %ecx,%eax
jmp    11ba <make_binding_object+0x6a>

LLVM IR (-O0):
@.str = [42 x i8] c"make_binding_object: command is too short\00"
@.str.1 = [3 x i8] c"IA\00"
@.str.2 = [25 x i8] c"unknown binding type: %s\00"
@.str.3 = [28 x i8] c"make_binding_object: failed\00"
define i32 @make_binding_object(i32 %0, i8** %1, i8** %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %6
store i8** %1, i8*** %7
store i8** %2, i8*** %8
store i32* %3, i32** %9
store i32 0, i32* %10
%12 = load i32, i32* %6
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %4
%15 = call i32 @warnx(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %5
br label %53
16: ; preds = %4
%17 = load i8**, i8*** %7
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %42
22: ; preds = %16
%23 = load i8**, i8*** %8
%24 = load i32*, i32** %9
%25 = call i64 @put32(i8** %23, i32* %24, i32 2)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %22
br label %51
28: ; preds = %22
%29 = load i32, i32* %6
%30 = sub nsw i32 %29, 1
%31 = load i8**, i8*** %7
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8**, i8*** %8
%34 = load i32*, i32** %9
%35 = call i32 @make_ia_object(i32 %30, i8** %32, i8** %33, i32* %34)
store i32 %35, i32* %11
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %28
store i32 -1, i32* %5
br label %53
38: ; preds = %28
%39 = load i32, i32* %11
%40 = load i32, i32* %10
%41 = add nsw i32 %40, %39
store i32 %41, i32* %10
br label %47
42: ; preds = %16
%43 = load i8**, i8*** %7
%44 = getelementptr inbounds i8*, i8** %43, i64 0
%45 = load i8*, i8** %44
%46 = call i32 @warn(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %45)
store i32 -1, i32* %5
br label %53
47: ; preds = %38
%48 = load i32, i32* %10
%49 = add nsw i32 %48, 1
store i32 %49, i32* %10
%50 = load i32, i32* %10
store i32 %50, i32* %5
br label %53
51: ; preds = %27
%52 = call i32 @warnx(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %5
br label %53
53: ; preds = %51, %47, %42, %37, %14
%54 = load i32, i32* %5
ret i32 %54
}

LLVM IR (-O2):
@.str = [42 x i8] c"make_binding_object: command is too short\00"
@.str.1 = [3 x i8] c"IA\00"
@.str.2 = [25 x i8] c"unknown binding type: %s\00"
@.str.3 = [28 x i8] c"make_binding_object: failed\00"
define i32 @make_binding_object(i32 %0, i8** %1, i8** %2, i32* %3) {
%5 = icmp eq i32 %0, 0
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = tail call i32 @warnx(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
br label %27
8: ; preds = %4
%9 = load i8*, i8** %1
%10 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %22
12: ; preds = %8
%13 = tail call i64 @put32(i8** %2, i32* %3, i32 2)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %25
15: ; preds = %12
%16 = add nsw i32 %0, -1
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = tail call i32 @make_ia_object(i32 %16, i8** %17, i8** %2, i32* %3)
%19 = add nsw i32 %18, 1
%20 = icmp sgt i32 %18, -1
%21 = select i1 %20, i32 %19, i32 -1
br label %27
22: ; preds = %8
%23 = load i8*, i8** %1
%24 = tail call i32 @warn(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %23)
br label %27
25: ; preds = %12
%26 = tail call i32 @warnx(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %27
27: ; preds = %15, %25, %22, %6
%28 = phi i32 [ -1, %6 ], [ -1, %25 ], [ -1, %22 ], [ %21, %15 ]
ret i32 %28
}