#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*/ convertBase(char *, int, int);
int getopt(int, char **, char *);
int /*<<< orphan*/ noArgument(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ showUsage(char *);
scalar_t__ strcmp(char *, char *);
void dec2oct(int argc, char **argv, char *applet) {
  int opt = 0;
  bool reverse = false;
  bool pr_help = false;
  while ((opt = getopt(argc, argv, "rh")) != -1) {
    switch (opt) {
    case 'r':
      reverse = true;
      break;
    case 'h':
      pr_help = true;
      break;
    }
  }
  if (!pr_help) {
    if (reverse) {
      if (argc > 2) {
        printf("DEC: ");
      } else {
        noArgument(applet);
      }
    } else {
      if (argc > 1) {
        printf("OCT: ");
      } else {
        noArgument(applet);
      }
    }
    for (int i = 1; i < argc; i++) {
      if (reverse) {
        if (strcmp(argv[i], "-r") == 0) {
          continue;
        }
        convertBase(argv[i], 8, 10);
      } else {
        convertBase(argv[i], 10, 8);
      }
    }
    printf("\n");
  } else {
    showUsage(applet);
  }
}


x86 assembly (clang, -O0):
<dec2oct>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe6a(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     11e4 <dec2oct+0x84>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x68,%eax
je     11d8 <dec2oct+0x78>
jmp    11bb <dec2oct+0x5b>
mov    -0x2c(%rbp),%eax
sub    $0x72,%eax
jne    11df <dec2oct+0x7f>
jmp    11cc <dec2oct+0x6c>
movl   $0x1,-0x20(%rbp)
jmp    11df <dec2oct+0x7f>
movl   $0x1,-0x24(%rbp)
jmp    1188 <dec2oct+0x28>
cmpl   $0x0,-0x24(%rbp)
jne    12ed <dec2oct+0x18d>
cmpl   $0x0,-0x20(%rbp)
je     1221 <dec2oct+0xc1>
cmpl   $0x2,-0x4(%rbp)
jle    1213 <dec2oct+0xb3>
lea    0xdfa(%rip),%rdi
call   1040 <printf@plt>
jmp    121c <dec2oct+0xbc>
mov    -0x18(%rbp),%rdi
call   1080 <noArgument@plt>
jmp    124a <dec2oct+0xea>
cmpl   $0x1,-0x4(%rbp)
jle    123c <dec2oct+0xdc>
lea    0xdd7(%rip),%rdi
call   1040 <printf@plt>
jmp    1245 <dec2oct+0xe5>
mov    -0x18(%rbp),%rdi
call   1080 <noArgument@plt>
jmp    124a <dec2oct+0xea>
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12dc <dec2oct+0x17c>
cmpl   $0x0,-0x20(%rbp)
je     12ae <dec2oct+0x14e>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd95(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    128e <dec2oct+0x12e>
jmp    12ce <dec2oct+0x16e>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x8,%esi
mov    $0xa,%edx
call   1070 <convertBase@plt>
jmp    12c9 <dec2oct+0x169>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0xa,%esi
mov    $0x8,%edx
call   1070 <convertBase@plt>
jmp    12ce <dec2oct+0x16e>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1251 <dec2oct+0xf1>
lea    0xd2f(%rip),%rdi
call   1040 <printf@plt>
jmp    12f6 <dec2oct+0x196>
mov    -0x18(%rbp),%rdi
call   1030 <showUsage@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dec2oct>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %r13d,%r13d
mov    $0x1,%r12b
lea    0xe70(%rip),%r15
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1070 <getopt@plt>
cmp    $0x72,%eax
je     11ae <dec2oct+0x3e>
cmp    $0x68,%eax
je     11b3 <dec2oct+0x43>
cmp    $0xffffffff,%eax
jne    1190 <dec2oct+0x20>
jmp    11bb <dec2oct+0x4b>
xor    %r12d,%r12d
jmp    1190 <dec2oct+0x20>
mov    $0x1,%r13d
jmp    1190 <dec2oct+0x20>
test   %r13d,%r13d
je     11d6 <dec2oct+0x66>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <showUsage@plt>
test   $0x1,%r12b
je     11ea <dec2oct+0x7a>
cmp    $0x1,%ebp
jle    11fd <dec2oct+0x8d>
lea    0xe21(%rip),%rdi
jmp    11f6 <dec2oct+0x86>
cmp    $0x2,%ebp
jle    1207 <dec2oct+0x97>
lea    0xe0d(%rip),%rdi
call   1050 <printf@plt>
jmp    1214 <dec2oct+0xa4>
mov    %r14,%rdi
call   1090 <noArgument@plt>
jmp    126f <dec2oct+0xff>
mov    %r14,%rdi
call   1090 <noArgument@plt>
cmp    $0x2,%ebp
jne    126f <dec2oct+0xff>
mov    %ebp,%r15d
mov    $0x1,%ebp
lea    0xdec(%rip),%r14
jmp    1248 <dec2oct+0xd8>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0xa,%esi
mov    $0x8,%edx
call   1080 <convertBase@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
je     126f <dec2oct+0xff>
mov    (%rbx,%rbp,8),%rdi
test   $0x1,%r12b
jne    1230 <dec2oct+0xc0>
mov    %r14,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     123f <dec2oct+0xcf>
mov    (%rbx,%rbp,8),%rdi
mov    $0x8,%esi
mov    $0xa,%edx
jmp    123a <dec2oct+0xca>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"rh\00"
@.str.1 = [6 x i8] c"DEC: \00"
@.str.2 = [6 x i8] c"OCT: \00"
@.str.3 = [3 x i8] c"-r\00"
@.str.4 = [2 x i8] c"\0A\00"
define void @dec2oct(i32 %0, i8** %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* %2, i8** %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
br label %11
11: ; preds = %20, %3
%12 = load i32, i32* %4
%13 = load i8**, i8*** %5
%14 = call i32 @getopt(i32 %12, i8** %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %14, i32* %7
%15 = icmp ne i32 %14, -1
br i1 %15, label %16, label %21
16: ; preds = %11
%17 = load i32, i32* %7
switch i32 %17, label %20 [
i32 114, label %18
i32 104, label %19
]
18: ; preds = %16
store i32 1, i32* %8
br label %20
19: ; preds = %16
store i32 1, i32* %9
br label %20
20: ; preds = %16, %19, %18
br label %11
21: ; preds = %11
%22 = load i32, i32* %9
%23 = icmp ne i32 %22, 0
br i1 %23, label %82, label %24
24: ; preds = %21
%25 = load i32, i32* %8
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %36
27: ; preds = %24
%28 = load i32, i32* %4
%29 = icmp sgt i32 %28, 2
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %35
32: ; preds = %27
%33 = load i8*, i8** %6
%34 = call i32 @noArgument(i8* %33)
br label %35
35: ; preds = %32, %30
br label %45
36: ; preds = %24
%37 = load i32, i32* %4
%38 = icmp sgt i32 %37, 1
br i1 %38, label %39, label %41
39: ; preds = %36
%40 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %44
41: ; preds = %36
%42 = load i8*, i8** %6
%43 = call i32 @noArgument(i8* %42)
br label %44
44: ; preds = %41, %39
br label %45
45: ; preds = %44, %35
store i32 1, i32* %10
br label %46
46: ; preds = %77, %45
%47 = load i32, i32* %10
%48 = load i32, i32* %4
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %80
50: ; preds = %46
%51 = load i32, i32* %8
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %69
53: ; preds = %50
%54 = load i8**, i8*** %5
%55 = load i32, i32* %10
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8*, i8** %54, i64 %56
%58 = load i8*, i8** %57
%59 = call i64 @strcmp(i8* %58, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %62
61: ; preds = %53
br label %77
62: ; preds = %53
%63 = load i8**, i8*** %5
%64 = load i32, i32* %10
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8*, i8** %63, i64 %65
%67 = load i8*, i8** %66
%68 = call i32 @convertBase(i8* %67, i32 8, i32 10)
br label %76
69: ; preds = %50
%70 = load i8**, i8*** %5
%71 = load i32, i32* %10
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i8*, i8** %70, i64 %72
%74 = load i8*, i8** %73
%75 = call i32 @convertBase(i8* %74, i32 10, i32 8)
br label %76
76: ; preds = %69, %62
br label %77
77: ; preds = %76, %61
%78 = load i32, i32* %10
%79 = add nsw i32 %78, 1
store i32 %79, i32* %10
br label %46
80: ; preds = %46
%81 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %85
82: ; preds = %21
%83 = load i8*, i8** %6
%84 = call i32 @showUsage(i8* %83)
br label %85
85: ; preds = %82, %80
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"rh\00"
@.str.1 = [6 x i8] c"DEC: \00"
@.str.2 = [6 x i8] c"OCT: \00"
@.str.3 = [3 x i8] c"-r\00"
define void @dec2oct(i32 %0, i8** %1, i8* %2) {
br label %4
4: ; preds = %9, %3
%5 = phi i1 [ true, %3 ], [ false, %9 ]
%6 = phi i32 [ 0, %3 ], [ %8, %9 ]
br label %7
7: ; preds = %9, %4
%8 = phi i32 [ %6, %4 ], [ 1, %9 ]
br label %9
9: ; preds = %7, %9
%10 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
switch i32 %10, label %9 [
i32 -1, label %11
i32 114, label %4
i32 104, label %7
]
11: ; preds = %9
%12 = icmp eq i32 %8, 0
br i1 %12, label %13, label %45
13: ; preds = %11
br i1 %5, label %16, label %14
14: ; preds = %13
%15 = icmp sgt i32 %0, 2
br i1 %15, label %23, label %20
16: ; preds = %13
%17 = icmp sgt i32 %0, 1
br i1 %17, label %23, label %18
18: ; preds = %16
%19 = tail call i32 @noArgument(i8* %2)
br label %28
20: ; preds = %14
%21 = tail call i32 @noArgument(i8* %2)
%22 = icmp eq i32 %0, 2
br i1 %22, label %26, label %28
23: ; preds = %16, %14
%24 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), %14 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %16 ]
%25 = tail call i32 @printf(i8* dereferenceable(1) %24)
br label %26
26: ; preds = %23, %20
%27 = zext i32 %0 to i64
br label %30
28: ; preds = %42, %18, %20
%29 = tail call i32 @putchar(i32 10)
br label %47
30: ; preds = %26, %42
%31 = phi i64 [ 1, %26 ], [ %43, %42 ]
%32 = getelementptr inbounds i8*, i8** %1, i64 %31
%33 = load i8*, i8** %32
br i1 %5, label %40, label %34
34: ; preds = %30
%35 = tail call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %42, label %37
37: ; preds = %34
%38 = load i8*, i8** %32
%39 = tail call i32 @convertBase(i8* %38, i32 8, i32 10)
br label %42
40: ; preds = %30
%41 = tail call i32 @convertBase(i8* %33, i32 10, i32 8)
br label %42
42: ; preds = %37, %40, %34
%43 = add nuw nsw i64 %31, 1
%44 = icmp eq i64 %43, %27
br i1 %44, label %28, label %30
45: ; preds = %11
%46 = tail call i32 @showUsage(i8* %2)
br label %47
47: ; preds = %45, %28
ret void
}