#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 */
struct c_command_line_option {
  int dummy;
};
struct c_command_line {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ c_command_line_option_delete(struct c_command_line_option *);
struct c_command_line_option *
c_command_line_option_new(char const *, char const *, char const *);
int c_command_line_option_set_value(struct c_command_line_option *,
                                    char const *, char const *);
int c_command_line_register_option(struct c_command_line *,
                                   struct c_command_line_option *);
int c_command_line_add_option(struct c_command_line *cmdline,
                              const char *short_name, const char *long_name,
                              const char *description, const char *value_name,
                              const char *default_value) {
  struct c_command_line_option *option;
  option = c_command_line_option_new(short_name, long_name, description);
  if (!option)
    return -1;
  if (c_command_line_option_set_value(option, value_name, default_value) ==
      -1) {
    c_command_line_option_delete(option);
    return -1;
  }
  if (c_command_line_register_option(cmdline, option) == -1) {
    c_command_line_option_delete(option);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<c_command_line_add_option>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <c_command_line_option_new@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    118c <c_command_line_add_option+0x4c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ed <c_command_line_add_option+0xad>
mov    -0x40(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
call   1060 <c_command_line_option_set_value@plt>
cmp    $0xffffffff,%eax
jne    11bb <c_command_line_add_option+0x7b>
mov    -0x40(%rbp),%rdi
call   1040 <c_command_line_option_delete@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ed <c_command_line_add_option+0xad>
mov    -0x10(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1050 <c_command_line_register_option@plt>
cmp    $0xffffffff,%eax
jne    11e6 <c_command_line_add_option+0xa6>
mov    -0x40(%rbp),%rdi
call   1040 <c_command_line_option_delete@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ed <c_command_line_add_option+0xad>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_command_line_add_option>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %r9,%r15
mov    %r8,%r12
mov    %rdi,%r14
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
call   1030 <c_command_line_option_new@plt>
mov    %rax,%rbx
mov    $0xffffffff,%eax
test   %rbx,%rbx
je     11a0 <c_command_line_add_option+0x60>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1060 <c_command_line_option_set_value@plt>
cmp    $0xffffffff,%eax
je     1193 <c_command_line_add_option+0x53>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <c_command_line_register_option@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
jne    11a0 <c_command_line_add_option+0x60>
mov    %rbx,%rdi
call   1040 <c_command_line_option_delete@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.c_command_line = type { i32 }
%struct.c_command_line_option = type { i32 }
define i32 @c_command_line_add_option(%struct.c_command_line* %0, i8* %1, i8* %2, i8* %3, i8* %4, i8* %5) {
%7 = alloca i32
%8 = alloca %struct.c_command_line*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca %struct.c_command_line_option*
store %struct.c_command_line* %0, %struct.c_command_line** %8
store i8* %1, i8** %9
store i8* %2, i8** %10
store i8* %3, i8** %11
store i8* %4, i8** %12
store i8* %5, i8** %13
%15 = load i8*, i8** %9
%16 = load i8*, i8** %10
%17 = load i8*, i8** %11
%18 = call %struct.c_command_line_option* @c_command_line_option_new(i8* %15, i8* %16, i8* %17)
store %struct.c_command_line_option* %18, %struct.c_command_line_option** %14
%19 = load %struct.c_command_line_option*, %struct.c_command_line_option** %14
%20 = icmp ne %struct.c_command_line_option* %19, null
br i1 %20, label %22, label %21
21: ; preds = %6
store i32 -1, i32* %7
br label %40
22: ; preds = %6
%23 = load %struct.c_command_line_option*, %struct.c_command_line_option** %14
%24 = load i8*, i8** %12
%25 = load i8*, i8** %13
%26 = call i32 @c_command_line_option_set_value(%struct.c_command_line_option* %23, i8* %24, i8* %25)
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %31
28: ; preds = %22
%29 = load %struct.c_command_line_option*, %struct.c_command_line_option** %14
%30 = call i32 @c_command_line_option_delete(%struct.c_command_line_option* %29)
store i32 -1, i32* %7
br label %40
31: ; preds = %22
%32 = load %struct.c_command_line*, %struct.c_command_line** %8
%33 = load %struct.c_command_line_option*, %struct.c_command_line_option** %14
%34 = call i32 @c_command_line_register_option(%struct.c_command_line* %32, %struct.c_command_line_option* %33)
%35 = icmp eq i32 %34, -1
br i1 %35, label %36, label %39
36: ; preds = %31
%37 = load %struct.c_command_line_option*, %struct.c_command_line_option** %14
%38 = call i32 @c_command_line_option_delete(%struct.c_command_line_option* %37)
store i32 -1, i32* %7
br label %40
39: ; preds = %31
store i32 0, i32* %7
br label %40
40: ; preds = %39, %36, %28, %21
%41 = load i32, i32* %7
ret i32 %41
}

LLVM IR (-O2):
%struct.c_command_line = type { i32 }
%struct.c_command_line_option = type { i32 }
define i32 @c_command_line_add_option(%struct.c_command_line* %0, i8* %1, i8* %2, i8* %3, i8* %4, i8* %5) {
%7 = tail call %struct.c_command_line_option* @c_command_line_option_new(i8* %1, i8* %2, i8* %3)
%8 = icmp eq %struct.c_command_line_option* %7, null
br i1 %8, label %17, label %9
9: ; preds = %6
%10 = tail call i32 @c_command_line_option_set_value(%struct.c_command_line_option* %7, i8* %4, i8* %5)
%11 = icmp eq i32 %10, -1
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = tail call i32 @c_command_line_register_option(%struct.c_command_line* %0, %struct.c_command_line_option* %7)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %17
15: ; preds = %12, %9
%16 = tail call i32 @c_command_line_option_delete(%struct.c_command_line_option* %7)
br label %17
17: ; preds = %15, %12, %6
%18 = phi i32 [ -1, %6 ], [ 0, %12 ], [ -1, %15 ]
ret i32 %18
}