#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 */
long strtol(char *, char **, int);
int fset_command_get_int_arg(int argc, char **argv, int arg_number,
                             int default_value) {
  long value;
  char *error;
  value = default_value;
  if (argc > arg_number) {
    error = NULL;
    value = strtol(argv[arg_number], &error, 10);
    if (!error || error[0])
      value = default_value;
  }
  return (int)value;
}


x86 assembly (clang, -O0):
<fset_command_get_int_arg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movslq -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    1187 <fset_command_get_int_arg+0x77>
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x28(%rbp),%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     117a <fset_command_get_int_arg+0x6a>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1182 <fset_command_get_int_arg+0x72>
movslq -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    1187 <fset_command_get_int_arg+0x77>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fset_command_get_int_arg>:
push   %rbx
sub    $0x10,%rsp
mov    %ecx,%ebx
cmp    %edx,%edi
jle    114c <fset_command_get_int_arg+0x3c>
movq   $0x0,0x8(%rsp)
movslq %edx,%rax
mov    (%rsi,%rax,8),%rdi
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    0x8(%rsp),%rcx
test   %rcx,%rcx
je     114c <fset_command_get_int_arg+0x3c>
cmpb   $0x0,(%rcx)
jne    114c <fset_command_get_int_arg+0x3c>
mov    %rax,%rbx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @fset_command_get_int_arg(i32 %0, i8** %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
%10 = alloca i8*
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%11 = load i32, i32* %8
%12 = sext i32 %11 to i64
store i64 %12, i64* %9
%13 = load i32, i32* %5
%14 = load i32, i32* %7
%15 = icmp sgt i32 %13, %14
br i1 %15, label %16, label %35
16: ; preds = %4
store i8* null, i8** %10
%17 = load i8**, i8*** %6
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
%21 = load i8*, i8** %20
%22 = call i64 @strtol(i8* %21, i8** %10, i32 10)
store i64 %22, i64* %9
%23 = load i8*, i8** %10
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %31
25: ; preds = %16
%26 = load i8*, i8** %10
%27 = getelementptr inbounds i8, i8* %26, i64 0
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %25, %16
%32 = load i32, i32* %8
%33 = sext i32 %32 to i64
store i64 %33, i64* %9
br label %34
34: ; preds = %31, %25
br label %35
35: ; preds = %34, %4
%36 = load i64, i64* %9
%37 = trunc i64 %36 to i32
ret i32 %37
}

LLVM IR (-O2):
define i32 @fset_command_get_int_arg(i32 %0, i8** nocapture %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = bitcast i8** %5 to i8*
%7 = zext i32 %3 to i64
%8 = icmp sgt i32 %0, %2
br i1 %8, label %9, label %20
9: ; preds = %4
store i8* null, i8** %5
%10 = sext i32 %2 to i64
%11 = getelementptr inbounds i8*, i8** %1, i64 %10
%12 = load i8*, i8** %11
%13 = call i64 @strtol(i8* %12, i8** %5, i32 10)
%14 = load i8*, i8** %5
%15 = icmp eq i8* %14, null
br i1 %15, label %19, label %16
16: ; preds = %9
%17 = load i8, i8* %14
%18 = icmp eq i8 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %16, %9
br label %20
20: ; preds = %16, %19, %4
%21 = phi i64 [ %7, %19 ], [ %13, %16 ], [ %7, %4 ]
%22 = trunc i64 %21 to i32
ret i32 %22
}