#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 /*<<< orphan*/ printf(char *, ...);
int scan(char *, char const **);
void c_set(char *arg[], const int argc) {
  extern int InNumBase, OutNumBase;
  int type, buff, i;
  const char *token[] = {"input",   "-i", "output", "-o",          "b", "bin",
                         "binary",  "o",  "oct",    "octal",       "d", "dec",
                         "decimal", "h",  "hex",    "hexadecimal", "\0"};
  enum {
    INPUT = 0,
    I,
    OUTPUT,
    O,
    C_B,
    C_BIN,
    C_BINARY,
    C_O,
    C_OCT,
    C_OCTAL,
    C_D,
    C_DEC,
    C_DECIMAL,
    C_H,
    C_HEX,
    C_HEXADECIMAL
  };
  if (argc >= 4)
    printf("error: too many arguments.\n");
  else if (argc != 3)
    printf("error: too few arguments.\n");
  else {
    i = 0;
    i = scan(arg[1], token);
    switch (i) {
    case INPUT:
    case I:
      type = INPUT;
      break;
    case OUTPUT:
    case O:
      type = OUTPUT;
      break;
    default:
      printf("error: '%s' is not a variable.\n", arg[1]);
      break;
    }
    i = 0;
    i = scan(arg[2], token);
    switch (i) {
    case C_B:
    case C_BIN:
    case C_BINARY:
      buff = 2;
      break;
    case C_O:
    case C_OCT:
    case C_OCTAL:
      buff = 8;
      break;
    case C_D:
    case C_DEC:
    case C_DECIMAL:
      buff = 10;
      break;
    case C_H:
    case C_HEX:
    case C_HEXADECIMAL:
      buff = 16;
      break;
    default:
      printf("error: '%s' is not a number base.\n", arg[2]);
      return;
      break;
    }
    switch (type) {
    case INPUT:
      InNumBase = buff;
      break;
    case OUTPUT:
      OutNumBase = buff;
      break;
    default:
      break;
    }
    return;
  }
}


x86 assembly (clang, -O0):
<c_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0xa0(%rbp),%rdi
lea    0x2c30(%rip),%rsi
mov    $0x88,%edx
call   1040 <memcpy@plt>
cmpl   $0x4,-0xc(%rbp)
jl     1177 <c_set+0x47>
lea    0xf09(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1301 <c_set+0x1d1>
cmpl   $0x3,-0xc(%rbp)
je     1194 <c_set+0x64>
lea    0xf08(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12fc <c_set+0x1cc>
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0xa0(%rbp),%rsi
call   1050 <scan@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0xa4(%rbp)
sub    $0x2,%eax
jb     11e0 <c_set+0xb0>
jmp    11c9 <c_set+0x99>
mov    -0xa4(%rbp),%eax
add    $0xfffffffe,%eax
sub    $0x2,%eax
jb     11ec <c_set+0xbc>
jmp    11f8 <c_set+0xc8>
movl   $0x0,-0x10(%rbp)
jmp    120e <c_set+0xde>
movl   $0x2,-0x10(%rbp)
jmp    120e <c_set+0xde>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0xa0(%rbp),%rsi
call   1050 <scan@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0xfffffffc,%eax
mov    %eax,%ecx
mov    %rcx,-0xb0(%rbp)
sub    $0xb,%eax
ja     128b <c_set+0x15b>
mov    -0xb0(%rbp),%rax
lea    0xdae(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x2,-0x14(%rbp)
jmp    12a6 <c_set+0x176>
movl   $0x8,-0x14(%rbp)
jmp    12a6 <c_set+0x176>
movl   $0xa,-0x14(%rbp)
jmp    12a6 <c_set+0x176>
movl   $0x10,-0x14(%rbp)
jmp    12a6 <c_set+0x176>
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1301 <c_set+0x1d1>
mov    -0x10(%rbp),%eax
mov    %eax,-0xb4(%rbp)
test   %eax,%eax
je     12d0 <c_set+0x1a0>
jmp    12bc <c_set+0x18c>
mov    -0xb4(%rbp),%eax
sub    $0x2,%eax
je     12e1 <c_set+0x1b1>
jmp    12f2 <c_set+0x1c2>
mov    -0x14(%rbp),%ecx
mov    0x2cfe(%rip),%rax
mov    %ecx,(%rax)
jmp    12f7 <c_set+0x1c7>
mov    -0x14(%rbp),%ecx
mov    0x2cf5(%rip),%rax
mov    %ecx,(%rax)
jmp    12f7 <c_set+0x1c7>
jmp    12f7 <c_set+0x1c7>
jmp    1301 <c_set+0x1d1>
jmp    1301 <c_set+0x1d1>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_set>:
push   %rbp
push   %rbx
sub    $0x88,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0x2c2b(%rip),%rsi
mov    %rsp,%rdi
mov    $0x88,%edx
call   1050 <memcpy@plt>
cmp    $0x4,%ebp
jl     1170 <c_set+0x30>
lea    0xf31(%rip),%rdi
jmp    119b <c_set+0x5b>
cmp    $0x3,%ebp
jne    1194 <c_set+0x54>
mov    0x8(%rbx),%rdi
mov    %rsp,%rsi
call   1060 <scan@plt>
cmp    $0x4,%eax
jae    11a9 <c_set+0x69>
cltq
lea    0xf61(%rip),%rcx
mov    (%rcx,%rax,4),%ebp
jmp    11bb <c_set+0x7b>
lea    0xeea(%rip),%rdi
add    $0x88,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <puts@plt>
mov    0x8(%rbx),%rsi
lea    0xe8e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rbx),%rdi
mov    %rsp,%rsi
call   1060 <scan@plt>
add    $0xfffffffc,%eax
cmp    $0xc,%eax
jae    11ed <c_set+0xad>
cltq
lea    0xee8(%rip),%rcx
mov    (%rcx,%rax,4),%eax
cmp    $0x2,%ebp
je     1201 <c_set+0xc1>
test   %ebp,%ebp
jne    120a <c_set+0xca>
mov    0x2ded(%rip),%rcx
jmp    1208 <c_set+0xc8>
mov    0x10(%rbx),%rsi
lea    0xe6a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    120a <c_set+0xca>
mov    0x2dd8(%rip),%rcx
mov    %eax,(%rcx)
add    $0x88,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"input\00"
@.str.1 = [3 x i8] c"-i\00"
@.str.2 = [7 x i8] c"output\00"
@.str.3 = [3 x i8] c"-o\00"
@.str.4 = [2 x i8] c"b\00"
@.str.5 = [4 x i8] c"bin\00"
@.str.6 = [7 x i8] c"binary\00"
@.str.7 = [2 x i8] c"o\00"
@.str.8 = [4 x i8] c"oct\00"
@.str.9 = [6 x i8] c"octal\00"
@.str.10 = [2 x i8] c"d\00"
@.str.11 = [4 x i8] c"dec\00"
@.str.12 = [8 x i8] c"decimal\00"
@.str.13 = [2 x i8] c"h\00"
@.str.14 = [4 x i8] c"hex\00"
@.str.15 = [12 x i8] c"hexadecimal\00"
@.str.16 = [2 x i8] zeroinitializer
@__const.c_set.token = [17 x i8*] [i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i32 0, i32 0)]
@.str.17 = [28 x i8] c"error: too many arguments.\0A\00"
@.str.18 = [27 x i8] c"error: too few arguments.\0A\00"
@.str.19 = [32 x i8] c"error: '%s' is not a variable.\0A\00"
@.str.20 = [35 x i8] c"error: '%s' is not a number base.\0A\00"
@InNumBase = external global i32
@OutNumBase = external global i32
define void @c_set(i8** %0, i32 %1) {
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [17 x i8*]
store i8** %0, i8*** %3
store i32 %1, i32* %4
%9 = bitcast [17 x i8*]* %8 to i8*
%10 = load i32, i32* %4
%11 = icmp sge i32 %10, 4
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.17, i64 0, i64 0))
br label %58
14: ; preds = %2
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 3
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.18, i64 0, i64 0))
br label %57
19: ; preds = %14
store i32 0, i32* %7
%20 = load i8**, i8*** %3
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = getelementptr inbounds [17 x i8*], [17 x i8*]* %8, i64 0, i64 0
%24 = call i32 @scan(i8* %22, i8** %23)
store i32 %24, i32* %7
%25 = load i32, i32* %7
switch i32 %25, label %28 [
i32 0, label %26
i32 1, label %26
i32 2, label %27
i32 3, label %27
]
26: ; preds = %19, %19
store i32 0, i32* %5
br label %33
27: ; preds = %19, %19
store i32 2, i32* %5
br label %33
28: ; preds = %19
%29 = load i8**, i8*** %3
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.19, i64 0, i64 0), i8* %31)
br label %33
33: ; preds = %28, %27, %26
store i32 0, i32* %7
%34 = load i8**, i8*** %3
%35 = getelementptr inbounds i8*, i8** %34, i64 2
%36 = load i8*, i8** %35
%37 = getelementptr inbounds [17 x i8*], [17 x i8*]* %8, i64 0, i64 0
%38 = call i32 @scan(i8* %36, i8** %37)
store i32 %38, i32* %7
%39 = load i32, i32* %7
switch i32 %39, label %44 [
i32 4, label %40
i32 5, label %40
i32 6, label %40
i32 7, label %41
i32 8, label %41
i32 9, label %41
i32 10, label %42
i32 11, label %42
i32 12, label %42
i32 13, label %43
i32 14, label %43
i32 15, label %43
]
40: ; preds = %33, %33, %33
store i32 2, i32* %6
br label %49
41: ; preds = %33, %33, %33
store i32 8, i32* %6
br label %49
42: ; preds = %33, %33, %33
store i32 10, i32* %6
br label %49
43: ; preds = %33, %33, %33
store i32 16, i32* %6
br label %49
44: ; preds = %33
%45 = load i8**, i8*** %3
%46 = getelementptr inbounds i8*, i8** %45, i64 2
%47 = load i8*, i8** %46
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.20, i64 0, i64 0), i8* %47)
br label %58
49: ; preds = %43, %42, %41, %40
%50 = load i32, i32* %5
switch i32 %50, label %55 [
i32 0, label %51
i32 2, label %53
]
51: ; preds = %49
%52 = load i32, i32* %6
store i32 %52, i32* @InNumBase
br label %56
53: ; preds = %49
%54 = load i32, i32* %6
store i32 %54, i32* @OutNumBase
br label %56
55: ; preds = %49
br label %56
56: ; preds = %55, %53, %51
br label %58
57: ; preds = %17
br label %58
58: ; preds = %44, %56, %57, %12
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"input\00"
@.str.1 = [3 x i8] c"-i\00"
@.str.2 = [7 x i8] c"output\00"
@.str.3 = [3 x i8] c"-o\00"
@.str.4 = [2 x i8] c"b\00"
@.str.5 = [4 x i8] c"bin\00"
@.str.6 = [7 x i8] c"binary\00"
@.str.7 = [2 x i8] c"o\00"
@.str.8 = [4 x i8] c"oct\00"
@.str.9 = [6 x i8] c"octal\00"
@.str.10 = [2 x i8] c"d\00"
@.str.11 = [4 x i8] c"dec\00"
@.str.12 = [8 x i8] c"decimal\00"
@.str.13 = [2 x i8] c"h\00"
@.str.14 = [4 x i8] c"hex\00"
@.str.15 = [12 x i8] c"hexadecimal\00"
@.str.16 = [2 x i8] zeroinitializer
@__const.c_set.token = [17 x i8*] [i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i32 0, i32 0)]
@.str.19 = [32 x i8] c"error: '%s' is not a variable.\0A\00"
@.str.20 = [35 x i8] c"error: '%s' is not a number base.\0A\00"
@InNumBase = external global i32
@OutNumBase = external global i32
@str = [26 x i8] c"error: too few arguments.\00"
@str.21 = [27 x i8] c"error: too many arguments.\00"
@switch.table.c_set = [4 x i32] [i32 0, i32 0, i32 2, i32 2]
@switch.table.c_set.22 = [12 x i32] [i32 2, i32 2, i32 2, i32 8, i32 8, i32 8, i32 10, i32 10, i32 10, i32 16, i32 16, i32 16]
define void @c_set(i8** nocapture %0, i32 %1) {
%3 = alloca [17 x i8*]
%4 = bitcast [17 x i8*]* %3 to i8*
%5 = icmp sgt i32 %1, 3
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.21, i64 0, i64 0))
br label %41
8: ; preds = %2
%9 = icmp eq i32 %1, 3
br i1 %9, label %12, label %10
10: ; preds = %8
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %41
12: ; preds = %8
%13 = getelementptr inbounds i8*, i8** %0, i64 1
%14 = load i8*, i8** %13
%15 = getelementptr inbounds [17 x i8*], [17 x i8*]* %3, i64 0, i64 0
%16 = call i32 @scan(i8* %14, i8** %15)
%17 = icmp ult i32 %16, 4
br i1 %17, label %21, label %18
18: ; preds = %12
%19 = load i8*, i8** %13
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.19, i64 0, i64 0), i8* %19)
br label %25
21: ; preds = %12
%22 = sext i32 %16 to i64
%23 = getelementptr inbounds [4 x i32], [4 x i32]* @switch.table.c_set, i64 0, i64 %22
%24 = load i32, i32* %23
br label %25
25: ; preds = %21, %18
%26 = phi i32 [ undef, %18 ], [ %24, %21 ]
%27 = getelementptr inbounds i8*, i8** %0, i64 2
%28 = load i8*, i8** %27
%29 = call i32 @scan(i8* %28, i8** %15)
%30 = add i32 %29, -4
%31 = icmp ult i32 %30, 12
br i1 %31, label %35, label %32
32: ; preds = %25
%33 = load i8*, i8** %27
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.20, i64 0, i64 0), i8* %33)
br label %41
35: ; preds = %25
%36 = sext i32 %30 to i64
%37 = getelementptr inbounds [12 x i32], [12 x i32]* @switch.table.c_set.22, i64 0, i64 %36
%38 = load i32, i32* %37
switch i32 %26, label %41 [
i32 0, label %39
i32 2, label %40
]
39: ; preds = %35
store i32 %38, i32* @InNumBase
br label %41
40: ; preds = %35
store i32 %38, i32* @OutNumBase
br label %41
41: ; preds = %6, %10, %39, %40, %35, %32
ret void
}