#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 */
typedef int /*<<< orphan*/ regex_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int DBL_MAX_10_EXP;
int EOF;
int /*<<< orphan*/ REG_EXTENDED;
int /*<<< orphan*/ exit(int);
scalar_t__ fabs(double);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ free(char *);
int getchar();
scalar_t__ getnum(double *, char *, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int log(int);
char *malloc(int);
scalar_t__ match(char *, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
char *rebase_d(double, unsigned int, char *, char *, char *);
int /*<<< orphan*/ regcomp(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ regfree(int /*<<< orphan*/ *);
int /*<<< orphan*/ stdin;
double strtod(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  unsigned base;
  int c, e;
  char *dptr, *fptr, *iptr;
  FILE *errlog;
  double num;
  regex_t renum;
  dptr = malloc(((DBL_MAX_10_EXP * (log(10) / log(2)) + 1) + 4));
  fptr = malloc((DBL_MAX_10_EXP * (log(10) / log(2)) + 1) + 1);
  iptr = malloc((DBL_MAX_10_EXP * (log(10) / log(2)) + 1) + 1);
  errlog = fopen(".rebaser.log", "a");
  regcomp(&renum, "^-?[0-9]*.?[0-9]+$", REG_EXTENDED);
  if (argc > 1) {
    if (match(argv[1], &renum, errlog) && strtod(argv[1], NULL) >= 2.0)
      base = (unsigned)fabs(strtod(argv[1], NULL));
    else {
      fprintf(errlog, "Bad base: [%s]\n", argv[1]);
      usage();
      exit(1);
    }
  } else if (!(getnum(&num, iptr, &renum, errlog) &&
               (base = (unsigned)fabs(num)) >= 2)) {
    fprintf(errlog, "Bad base: [%d]\n", base);
    usage();
    exit(1);
  }
  if (argc > 2) {
    for (e = 2; e < argc; ++e)
      if (match(argv[e], &renum, errlog))
        printf("%s\n", rebase_d(strtod(argv[e], NULL), base, dptr, fptr, iptr));
    goto end;
  }
  while ((c = getchar()) != EOF) {
    ungetc(c, stdin);
    if (getnum(&num, iptr, &renum, errlog))
      printf("%s\n", rebase_d(num, base, dptr, fptr, iptr));
  }
end:
  fclose(errlog);
  free(dptr);
  free(fptr);
  free(iptr);
  regfree(&renum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2db3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    $0xa,%edi
call   1120 <log@plt>
mov    %eax,-0x60(%rbp)
mov    $0x2,%edi
call   1120 <log@plt>
mov    -0x64(%rbp),%edi
mov    %eax,%ecx
mov    -0x60(%rbp),%eax
cltd
idiv   %ecx
imul   %eax,%edi
add    $0x1,%edi
add    $0x4,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    0x2d73(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
mov    $0xa,%edi
call   1120 <log@plt>
mov    %eax,-0x58(%rbp)
mov    $0x2,%edi
call   1120 <log@plt>
mov    -0x5c(%rbp),%edi
mov    %eax,%ecx
mov    -0x58(%rbp),%eax
cltd
idiv   %ecx
imul   %eax,%edi
add    $0x1,%edi
add    $0x1,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    0x2d33(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    $0xa,%edi
call   1120 <log@plt>
mov    %eax,-0x50(%rbp)
mov    $0x2,%edi
call   1120 <log@plt>
mov    -0x54(%rbp),%edi
mov    %eax,%ecx
mov    -0x50(%rbp),%eax
cltd
idiv   %ecx
imul   %eax,%edi
add    $0x1,%edi
add    $0x1,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x38(%rbp)
lea    0xd0b(%rip),%rdi
lea    0xd11(%rip),%rsi
call   1130 <fopen@plt>
mov    %rax,-0x40(%rbp)
mov    0x2cb4(%rip),%rax
mov    (%rax),%edx
lea    -0x4c(%rbp),%rdi
lea    0xcf6(%rip),%rsi
call   1090 <regcomp@plt>
cmpl   $0x1,-0x8(%rbp)
jle    13c0 <main+0x1a0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x40(%rbp),%rdx
lea    -0x4c(%rbp),%rsi
call   1100 <match@plt>
cmp    $0x0,%rax
je     1390 <main+0x170>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <strtod@plt>
movsd  0xc98(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1390 <main+0x170>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <strtod@plt>
call   10a0 <fabs@plt>
mov    %eax,-0x14(%rbp)
jmp    13bb <main+0x19b>
mov    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xc87(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    $0x0,%al
call   1110 <usage@plt>
mov    $0x1,%edi
call   1140 <exit@plt>
jmp    1420 <main+0x200>
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rcx
lea    -0x48(%rbp),%rdi
lea    -0x4c(%rbp),%rdx
call   1030 <getnum@plt>
cmp    $0x0,%rax
je     13f5 <main+0x1d5>
movsd  -0x48(%rbp),%xmm0
call   10a0 <fabs@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x2,%eax
jae    141b <main+0x1fb>
mov    -0x40(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xc37(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    $0x0,%al
call   1110 <usage@plt>
mov    $0x1,%edi
call   1140 <exit@plt>
jmp    1420 <main+0x200>
cmpl   $0x2,-0x8(%rbp)
jle    14b0 <main+0x290>
movl   $0x2,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    14ab <main+0x28b>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x40(%rbp),%rdx
lea    -0x4c(%rbp),%rsi
call   1100 <match@plt>
cmp    $0x0,%rax
je     1498 <main+0x278>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <strtod@plt>
mov    -0x14(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
call   10d0 <rebase_d@plt>
mov    %rax,%rsi
lea    0xbb7(%rip),%rdi
call   1080 <printf@plt>
jmp    149d <main+0x27d>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1431 <main+0x211>
jmp    1530 <main+0x310>
jmp    14b5 <main+0x295>
mov    $0x0,%al
call   10b0 <getchar@plt>
mov    %eax,-0x18(%rbp)
mov    0x2b12(%rip),%rcx
cmp    (%rcx),%eax
je     152b <main+0x30b>
mov    -0x18(%rbp),%edi
mov    0x2b08(%rip),%rax
mov    (%rax),%esi
call   10f0 <ungetc@plt>
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rcx
lea    -0x48(%rbp),%rdi
lea    -0x4c(%rbp),%rdx
call   1030 <getnum@plt>
cmp    $0x0,%rax
je     1526 <main+0x306>
movsd  -0x48(%rbp),%xmm0
mov    -0x14(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
call   10d0 <rebase_d@plt>
mov    %rax,%rsi
lea    0xb29(%rip),%rdi
call   1080 <printf@plt>
jmp    14b5 <main+0x295>
jmp    1530 <main+0x310>
mov    -0x40(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1040 <free@plt>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
lea    -0x4c(%rbp),%rdi
call   1070 <regfree@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r15
mov    %edi,%r12d
mov    0x2db5(%rip),%r14
mov    (%r14),%ebx
mov    $0xa,%edi
call   1120 <log@plt>
mov    %eax,%ebp
mov    $0x2,%edi
call   1120 <log@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
imul   %eax,%ebx
add    $0x5,%ebx
mov    %ebx,%edi
call   10e0 <malloc@plt>
mov    %rax,0x18(%rsp)
mov    (%r14),%ebx
mov    $0xa,%edi
call   1120 <log@plt>
mov    %eax,%ebp
mov    $0x2,%edi
call   1120 <log@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
imul   %eax,%ebx
add    $0x2,%ebx
mov    %ebx,%edi
call   10e0 <malloc@plt>
mov    %rax,0x10(%rsp)
mov    (%r14),%ebx
mov    $0xa,%edi
call   1120 <log@plt>
mov    %eax,%ebp
mov    $0x2,%edi
call   1120 <log@plt>
mov    %eax,%ecx
mov    %ebp,%eax
mov    %r12d,%ebp
cltd
idiv   %ecx
imul   %eax,%ebx
add    $0x2,%ebx
mov    %ebx,%edi
call   10e0 <malloc@plt>
mov    %rax,%rbx
lea    0xd2f(%rip),%rdi
lea    0xd35(%rip),%rsi
call   1130 <fopen@plt>
mov    %rax,%r12
mov    0x2cd9(%rip),%rax
mov    (%rax),%edx
lea    0xd1f(%rip),%rsi
lea    0xc(%rsp),%rdi
call   1090 <regcomp@plt>
cmp    $0x2,%ebp
jl     13c4 <main+0x1a4>
mov    0x8(%r15),%rdi
lea    0xc(%rsp),%rsi
mov    %r12,%rdx
call   1100 <match@plt>
test   %rax,%rax
je     14ae <main+0x28e>
mov    0x8(%r15),%rdi
xor    %esi,%esi
call   1050 <strtod@plt>
ucomisd 0xcc8(%rip),%xmm0
jb     14ae <main+0x28e>
mov    0x8(%r15),%rdi
xor    %esi,%esi
call   1050 <strtod@plt>
call   10a0 <fabs@plt>
mov    %rax,%r13
cmp    $0x3,%ebp
jb     13f1 <main+0x1d1>
mov    %ebp,%ebp
mov    $0x2,%r14d
jmp    137d <main+0x15d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r14
cmp    %r14,%rbp
je     1404 <main+0x1e4>
mov    (%r15,%r14,8),%rdi
lea    0xc(%rsp),%rsi
mov    %r12,%rdx
call   1100 <match@plt>
test   %rax,%rax
je     1370 <main+0x150>
mov    (%r15,%r14,8),%rdi
xor    %esi,%esi
call   1050 <strtod@plt>
mov    %r13d,%edi
mov    0x18(%rsp),%rsi
mov    0x10(%rsp),%rdx
mov    %rbx,%rcx
call   10d0 <rebase_d@plt>
lea    0xc90(%rip),%rdi
mov    %rax,%rsi
call   1080 <printf@plt>
jmp    1370 <main+0x150>
lea    0x20(%rsp),%rdi
lea    0xc(%rsp),%rdx
mov    %rbx,%rsi
mov    %r12,%rcx
call   1030 <getnum@plt>
movsd  0x20(%rsp),%xmm0
call   10a0 <fabs@plt>
mov    %rax,%r13
cmp    $0x1,%r13d
jbe    14c5 <main+0x2a5>
xor    %eax,%eax
call   10b0 <getchar@plt>
mov    0x2bd9(%rip),%r15
cmp    (%r15),%eax
jne    1443 <main+0x223>
mov    %r12,%rdi
call   1060 <fclose@plt>
mov    0x18(%rsp),%rdi
call   1040 <free@plt>
mov    0x10(%rsp),%rdi
call   1040 <free@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
lea    0xc(%rsp),%rdi
call   1070 <regfree@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x20(%rsp),%rbp
lea    0xc(%rsp),%r14
jmp    145c <main+0x23c>
nop
xor    %eax,%eax
call   10b0 <getchar@plt>
cmp    (%r15),%eax
je     1404 <main+0x1e4>
mov    0x2b7d(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
call   10f0 <ungetc@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r12,%rcx
call   1030 <getnum@plt>
test   %rax,%rax
je     1450 <main+0x230>
movsd  0x20(%rsp),%xmm0
mov    %r13d,%edi
mov    0x18(%rsp),%rsi
mov    0x10(%rsp),%rdx
mov    %rbx,%rcx
call   10d0 <rebase_d@plt>
lea    0xba6(%rip),%rdi
mov    %rax,%rsi
call   1080 <printf@plt>
jmp    1450 <main+0x230>
mov    0x8(%r15),%rdx
lea    0xb71(%rip),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   10c0 <fprintf@plt>
jmp    14d9 <main+0x2b9>
lea    0xb6e(%rip),%rsi
mov    %r12,%rdi
mov    %r13d,%edx
xor    %eax,%eax
call   10c0 <fprintf@plt>
xor    %eax,%eax
call   1110 <usage@plt>
mov    $0x1,%edi
call   1140 <exit@plt>

LLVM IR (-O0):
@DBL_MAX_10_EXP = global i32 0
@.str = [13 x i8] c".rebaser.log\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [19 x i8] c"^-?[0-9]*.?[0-9]+$\00"
@REG_EXTENDED = global i32 0
@.str.3 = [16 x i8] c"Bad base: [%s]\0A\00"
@.str.4 = [16 x i8] c"Bad base: [%d]\0A\00"
@.str.5 = [4 x i8] c"%s\0A\00"
@EOF = global i32 0
@stdin = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32*
%13 = alloca double
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* @DBL_MAX_10_EXP
%16 = call i32 @log(i32 10)
%17 = call i32 @log(i32 2)
%18 = sdiv i32 %16, %17
%19 = mul nsw i32 %15, %18
%20 = add nsw i32 %19, 1
%21 = add nsw i32 %20, 4
%22 = call i8* @malloc(i32 %21)
store i8* %22, i8** %9
%23 = load i32, i32* @DBL_MAX_10_EXP
%24 = call i32 @log(i32 10)
%25 = call i32 @log(i32 2)
%26 = sdiv i32 %24, %25
%27 = mul nsw i32 %23, %26
%28 = add nsw i32 %27, 1
%29 = add nsw i32 %28, 1
%30 = call i8* @malloc(i32 %29)
store i8* %30, i8** %10
%31 = load i32, i32* @DBL_MAX_10_EXP
%32 = call i32 @log(i32 10)
%33 = call i32 @log(i32 2)
%34 = sdiv i32 %32, %33
%35 = mul nsw i32 %31, %34
%36 = add nsw i32 %35, 1
%37 = add nsw i32 %36, 1
%38 = call i8* @malloc(i32 %37)
store i8* %38, i8** %11
%39 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %39, i32** %12
%40 = load i32, i32* @REG_EXTENDED
%41 = call i32 @regcomp(i32* %14, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %4
%43 = icmp sgt i32 %42, 1
br i1 %43, label %44, label %73
44: ; preds = %2
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 1
%47 = load i8*, i8** %46
%48 = load i32*, i32** %12
%49 = call i64 @match(i8* %47, i32* %14, i32* %48)
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %64
51: ; preds = %44
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 1
%54 = load i8*, i8** %53
%55 = call double @strtod(i8* %54, i32* null)
%56 = fcmp oge double %55, 2.000000e+00
br i1 %56, label %57, label %64
57: ; preds = %51
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i64 1
%60 = load i8*, i8** %59
%61 = call double @strtod(i8* %60, i32* null)
%62 = call i64 @fabs(double %61)
%63 = trunc i64 %62 to i32
store i32 %63, i32* %6
br label %72
64: ; preds = %51, %44
%65 = load i32*, i32** %12
%66 = load i8**, i8*** %5
%67 = getelementptr inbounds i8*, i8** %66, i64 1
%68 = load i8*, i8** %67
%69 = call i32 (i32*, i8*, ...) @fprintf(i32* %65, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %68)
%70 = call i32 (...) @usage()
%71 = call i32 @exit(i32 1)
unreachable
72: ; preds = %57
br label %90
73: ; preds = %2
%74 = load i8*, i8** %11
%75 = load i32*, i32** %12
%76 = call i64 @getnum(double* %13, i8* %74, i32* %14, i32* %75)
%77 = icmp ne i64 %76, 0
br i1 %77, label %78, label %83
78: ; preds = %73
%79 = load double, double* %13
%80 = call i64 @fabs(double %79)
%81 = trunc i64 %80 to i32
store i32 %81, i32* %6
%82 = icmp uge i32 %81, 2
br i1 %82, label %89, label %83
83: ; preds = %78, %73
%84 = load i32*, i32** %12
%85 = load i32, i32* %6
%86 = call i32 (i32*, i8*, ...) @fprintf(i32* %84, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %85)
%87 = call i32 (...) @usage()
%88 = call i32 @exit(i32 1)
unreachable
89: ; preds = %78
br label %90
90: ; preds = %89, %72
%91 = load i32, i32* %4
%92 = icmp sgt i32 %91, 2
br i1 %92, label %93, label %125
93: ; preds = %90
store i32 2, i32* %8
br label %94
94: ; preds = %121, %93
%95 = load i32, i32* %8
%96 = load i32, i32* %4
%97 = icmp slt i32 %95, %96
br i1 %97, label %98, label %124
98: ; preds = %94
%99 = load i8**, i8*** %5
%100 = load i32, i32* %8
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds i8*, i8** %99, i64 %101
%103 = load i8*, i8** %102
%104 = load i32*, i32** %12
%105 = call i64 @match(i8* %103, i32* %14, i32* %104)
%106 = icmp ne i64 %105, 0
br i1 %106, label %107, label %120
107: ; preds = %98
%108 = load i8**, i8*** %5
%109 = load i32, i32* %8
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds i8*, i8** %108, i64 %110
%112 = load i8*, i8** %111
%113 = call double @strtod(i8* %112, i32* null)
%114 = load i32, i32* %6
%115 = load i8*, i8** %9
%116 = load i8*, i8** %10
%117 = load i8*, i8** %11
%118 = call i8* @rebase_d(double %113, i32 %114, i8* %115, i8* %116, i8* %117)
%119 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %118)
br label %120
120: ; preds = %107, %98
br label %121
121: ; preds = %120
%122 = load i32, i32* %8
%123 = add nsw i32 %122, 1
store i32 %123, i32* %8
br label %94
124: ; preds = %94
br label %148
125: ; preds = %90
br label %126
126: ; preds = %146, %125
%127 = call i32 (...) @getchar()
store i32 %127, i32* %7
%128 = load i32, i32* @EOF
%129 = icmp ne i32 %127, %128
br i1 %129, label %130, label %147
130: ; preds = %126
%131 = load i32, i32* %7
%132 = load i32, i32* @stdin
%133 = call i32 @ungetc(i32 %131, i32 %132)
%134 = load i8*, i8** %11
%135 = load i32*, i32** %12
%136 = call i64 @getnum(double* %13, i8* %134, i32* %14, i32* %135)
%137 = icmp ne i64 %136, 0
br i1 %137, label %138, label %146
138: ; preds = %130
%139 = load double, double* %13
%140 = load i32, i32* %6
%141 = load i8*, i8** %9
%142 = load i8*, i8** %10
%143 = load i8*, i8** %11
%144 = call i8* @rebase_d(double %139, i32 %140, i8* %141, i8* %142, i8* %143)
%145 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %144)
br label %146
146: ; preds = %138, %130
br label %126
147: ; preds = %126
br label %148
148: ; preds = %147, %124
%149 = load i32*, i32** %12
%150 = call i32 @fclose(i32* %149)
%151 = load i8*, i8** %9
%152 = call i32 @free(i8* %151)
%153 = load i8*, i8** %10
%154 = call i32 @free(i8* %153)
%155 = load i8*, i8** %11
%156 = call i32 @free(i8* %155)
%157 = call i32 @regfree(i32* %14)
ret i32 0
}

LLVM IR (-O2):
@DBL_MAX_10_EXP = global i32 0
@.str = [13 x i8] c".rebaser.log\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [19 x i8] c"^-?[0-9]*.?[0-9]+$\00"
@REG_EXTENDED = global i32 0
@.str.3 = [16 x i8] c"Bad base: [%s]\0A\00"
@.str.4 = [16 x i8] c"Bad base: [%d]\0A\00"
@.str.5 = [4 x i8] c"%s\0A\00"
@EOF = global i32 0
@stdin = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca double
%4 = alloca i32
%5 = bitcast double* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = load i32, i32* @DBL_MAX_10_EXP
%8 = tail call i32 @log(i32 10)
%9 = tail call i32 @log(i32 2)
%10 = sdiv i32 %8, %9
%11 = mul nsw i32 %10, %7
%12 = add nsw i32 %11, 5
%13 = tail call i8* @malloc(i32 %12)
%14 = load i32, i32* @DBL_MAX_10_EXP
%15 = tail call i32 @log(i32 10)
%16 = tail call i32 @log(i32 2)
%17 = sdiv i32 %15, %16
%18 = mul nsw i32 %17, %14
%19 = add nsw i32 %18, 2
%20 = tail call i8* @malloc(i32 %19)
%21 = load i32, i32* @DBL_MAX_10_EXP
%22 = tail call i32 @log(i32 10)
%23 = tail call i32 @log(i32 2)
%24 = sdiv i32 %22, %23
%25 = mul nsw i32 %24, %21
%26 = add nsw i32 %25, 2
%27 = tail call i8* @malloc(i32 %26)
%28 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%29 = load i32, i32* @REG_EXTENDED
%30 = call i32 @regcomp(i32* %4, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %29)
%31 = icmp sgt i32 %0, 1
br i1 %31, label %32, label %46
32: ; preds = %2
%33 = getelementptr inbounds i8*, i8** %1, i64 1
%34 = load i8*, i8** %33
%35 = call i64 @match(i8* %34, i32* %4, i32* %28)
%36 = icmp eq i64 %35, 0
br i1 %36, label %41, label %37
37: ; preds = %32
%38 = load i8*, i8** %33
%39 = call double @strtod(i8* nocapture %38, i32* null)
%40 = fcmp ult double %39, 2.000000e+00
br i1 %40, label %41, label %57
41: ; preds = %37, %32
%42 = load i8*, i8** %33
%43 = call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %42)
%44 = call i32 (...) @usage()
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %2
%47 = call i64 @getnum(double* %3, i8* %27, i32* %4, i32* %28)
%48 = icmp ne i64 %47, 0
%49 = load double, double* %3
%50 = call i64 @fabs(double %49)
%51 = trunc i64 %50 to i32
%52 = icmp ugt i32 %51, 1
br i1 %52, label %65, label %53
53: ; preds = %46
%54 = call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %51)
%55 = call i32 (...) @usage()
%56 = call i32 @exit(i32 1)
unreachable
57: ; preds = %37
%58 = load i8*, i8** %33
%59 = call double @strtod(i8* nocapture %58, i32* null)
%60 = call i64 @fabs(double %59)
%61 = trunc i64 %60 to i32
%62 = icmp ugt i32 %0, 2
br i1 %62, label %63, label %65
63: ; preds = %57
%64 = zext i32 %0 to i64
br label %70
65: ; preds = %46, %57
%66 = phi i32 [ %61, %57 ], [ %51, %46 ]
%67 = call i32 (...) @getchar()
%68 = load i32, i32* @EOF
%69 = icmp eq i32 %67, %68
br i1 %69, label %98, label %84
70: ; preds = %63, %81
%71 = phi i64 [ 2, %63 ], [ %82, %81 ]
%72 = getelementptr inbounds i8*, i8** %1, i64 %71
%73 = load i8*, i8** %72
%74 = call i64 @match(i8* %73, i32* %4, i32* %28)
%75 = icmp eq i64 %74, 0
br i1 %75, label %81, label %76
76: ; preds = %70
%77 = load i8*, i8** %72
%78 = call double @strtod(i8* nocapture %77, i32* null)
%79 = call i8* @rebase_d(double %78, i32 %61, i8* %13, i8* %20, i8* %27)
%80 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %79)
br label %81
81: ; preds = %70, %76
%82 = add nuw nsw i64 %71, 1
%83 = icmp eq i64 %82, %64
br i1 %83, label %98, label %70
84: ; preds = %65, %94
%85 = phi i32 [ %95, %94 ], [ %67, %65 ]
%86 = load i32, i32* @stdin
%87 = call i32 @ungetc(i32 %85, i32 %86)
%88 = call i64 @getnum(double* %3, i8* %27, i32* %4, i32* %28)
%89 = icmp eq i64 %88, 0
br i1 %89, label %94, label %90
90: ; preds = %84
%91 = load double, double* %3
%92 = call i8* @rebase_d(double %91, i32 %66, i8* %13, i8* %20, i8* %27)
%93 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %92)
br label %94
94: ; preds = %90, %84
%95 = call i32 (...) @getchar()
%96 = load i32, i32* @EOF
%97 = icmp eq i32 %95, %96
br i1 %97, label %98, label %84
98: ; preds = %94, %81, %65
%99 = call i32 @fclose(i32* %28)
%100 = call i32 @free(i8* %13)
%101 = call i32 @free(i8* %20)
%102 = call i32 @free(i8* %27)
%103 = call i32 @regfree(i32* %4)
ret i32 0
}