#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 htoi(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  if (argc > 1) {
    if (argc != 2) {
      printf("Warn: too many args.");
    }
    printf("%d\n", htoi(argv[1]));
  } else {
    char s[] = "0xff";
    printf(
        "Info: not specified hexadecimal digits, will use default value: %s.\n",
        s);
    printf("%d\n", htoi(s));
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    117a <main+0x5a>
cmpl   $0x2,-0x8(%rbp)
je     1158 <main+0x38>
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <htoi@plt>
mov    %eax,%esi
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b7 <main+0x97>
mov    0xe99(%rip),%eax
mov    %eax,-0x15(%rbp)
mov    0xe94(%rip),%al
mov    %al,-0x11(%rbp)
lea    -0x15(%rbp),%rsi
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x15(%rbp),%rdi
call   1040 <htoi@plt>
mov    %eax,%esi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jl     1143 <main+0x23>
mov    %rsi,%rbx
je     113d <main+0x1d>
lea    0xeca(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rbx),%rdi
jmp    1169 <main+0x49>
movb   $0x0,0xc(%rsp)
movl   $0x66667830,0x8(%rsp)
66
lea    0xec7(%rip),%rdi
lea    0x8(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <htoi@plt>
lea    0xea0(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Warn: too many args.\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@__const.main.s = [5 x i8] c"0xff\00"
@.str.2 = [69 x i8] c"Info: not specified hexadecimal digits, will use default value: %s.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [5 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %20
9: ; preds = %2
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %12, %9
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @htoi(i8* %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %18)
br label %27
20: ; preds = %2
%21 = bitcast [5 x i8]* %6 to i8*
%22 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%25 = call i32 @htoi(i8* %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %20, %14
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@.str = [21 x i8] c"Warn: too many args.\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@__const.main.s = [5 x i8] c"0xff\00"
@.str.2 = [69 x i8] c"Info: not specified hexadecimal digits, will use default value: %s.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [5 x i8]
%4 = icmp sgt i32 %0, 1
br i1 %4, label %5, label %14
5: ; preds = %2
%6 = icmp eq i32 %0, 2
br i1 %6, label %9, label %7
7: ; preds = %5
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %5
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @htoi(i8* %11)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %12)
br label %19
14: ; preds = %2
%15 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%17 = call i32 @htoi(i8* %15)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %14, %9
ret i32 0
}