#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 decodeNegativeBase(char *, long);
int /*<<< orphan*/ encodeNegativeBase(long, long, char *);
int /*<<< orphan*/ printf(char *, ...);
void driver(long n, long b) {
  char buf[64];
  long value;
  encodeNegativeBase(n, b, buf);
  printf("%12d encoded in base %3d = %12s\n", n, b, buf);
  value = decodeNegativeBase(buf, b);
  printf("%12s decoded in base %3d = %12d\n", buf, b, value);
  printf("\n");
}


x86 assembly (clang, -O0):
<driver>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x50(%rbp),%rdx
call   1040 <encodeNegativeBase@plt>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    -0x50(%rbp),%rcx
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <decodeNegativeBase@plt>
mov    %rax,-0x58(%rbp)
lea    -0x50(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x58(%rbp),%rcx
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<driver>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsp,%r15
mov    %r15,%rdx
call   1050 <encodeNegativeBase@plt>
lea    0xe9f(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <decodeNegativeBase@plt>
lea    0xe9e(%rip),%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [33 x i8] c"%12d encoded in base %3d = %12s\0A\00"
@.str.1 = [33 x i8] c"%12s decoded in base %3d = %12d\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @driver(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca [64 x i8]
%6 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%7 = load i64, i64* %3
%8 = load i64, i64* %4
%9 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%10 = call i32 @encodeNegativeBase(i64 %7, i64 %8, i8* %9)
%11 = load i64, i64* %3
%12 = load i64, i64* %4
%13 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i64 %11, i64 %12, i8* %13)
%15 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%16 = load i64, i64* %4
%17 = call i64 @decodeNegativeBase(i8* %15, i64 %16)
store i64 %17, i64* %6
%18 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%19 = load i64, i64* %4
%20 = load i64, i64* %6
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %18, i64 %19, i64 %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c"%12d encoded in base %3d = %12s\0A\00"
@.str.1 = [33 x i8] c"%12s decoded in base %3d = %12d\0A\00"
define void @driver(i64 %0, i64 %1) {
%3 = alloca [64 x i8]
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%5 = call i32 @encodeNegativeBase(i64 %0, i64 %1, i8* %4)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i64 %0, i64 %1, i8* %4)
%7 = call i64 @decodeNegativeBase(i8* %4, i64 %1)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %4, i64 %1, i64 %7)
%9 = call i32 @putchar(i32 10)
ret void
}