#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_register_option(struct c_command_line *,
                                   struct c_command_line_option *);
int c_command_line_add_flag(struct c_command_line *cmdline,
                            const char *short_name, const char *long_name,
                            const char *description) {
  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_register_option(cmdline, option) == -1) {
    c_command_line_option_delete(option);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<c_command_line_add_flag>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <c_command_line_option_new@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1174 <c_command_line_add_flag+0x44>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a6 <c_command_line_add_flag+0x76>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1050 <c_command_line_register_option@plt>
cmp    $0xffffffff,%eax
jne    119f <c_command_line_add_flag+0x6f>
mov    -0x30(%rbp),%rdi
call   1040 <c_command_line_option_delete@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a6 <c_command_line_add_flag+0x76>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_command_line_add_flag>:
push   %r14
push   %rbx
push   %rax
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     1173 <c_command_line_add_flag+0x43>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <c_command_line_register_option@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
jne    1173 <c_command_line_add_flag+0x43>
mov    %rbx,%rdi
call   1040 <c_command_line_option_delete@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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