#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*/ buf;

/* Variables and functions */
scalar_t__ base_convert(unsigned int, int, int, char *);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, unsigned int *);
int main(void) {
  unsigned n;
  char buf[256];
  printf("0以上の10進数を入力: ");
  if (scanf("%u", &n) != 1) {
    return 1;
  }
  for (int i = 2; i <= 16; ++i) {
    if (base_convert(n, i, sizeof(buf), buf)) {
      printf("%2d進数表記: %s\n", i, buf);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
je     1175 <main+0x45>
movl   $0x1,-0x4(%rbp)
jmp    11eb <main+0xbb>
movl   $0x2,-0x114(%rbp)
cmpl   $0x10,-0x114(%rbp)
jg     11e4 <main+0xb4>
mov    -0x8(%rbp),%edi
mov    -0x114(%rbp),%esi
lea    -0x110(%rbp),%rcx
mov    $0x100,%edx
call   1030 <base_convert@plt>
cmp    $0x0,%rax
je     11cb <main+0x9b>
mov    -0x114(%rbp),%esi
lea    -0x110(%rbp),%rdx
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11d0 <main+0xa0>
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    117f <main+0x4f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x110,%rsp
lea    0xebd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecd(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    $0x1,%ecx
jne    11b3 <main+0x83>
mov    $0x2,%ebx
lea    0x10(%rsp),%r14
lea    0xea9(%rip),%r15
jmp    1188 <main+0x58>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebx
cmp    $0x11,%ebx
je     11b1 <main+0x81>
mov    0xc(%rsp),%edi
mov    %ebx,%esi
mov    $0x100,%edx
mov    %r14,%rcx
call   1030 <base_convert@plt>
test   %rax,%rax
je     1180 <main+0x50>
mov    %r15,%rdi
mov    %ebx,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1180 <main+0x50>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [30 x i8] c"0\E4\BB\A5\E4\B8\8A\E3\81\AE10\E9\80\B2\E6\95\B0\E3\82\92\E5\85\A5\E5\8A\9B: \00"
@.str.1 = [3 x i8] c"%u\00"
@.str.2 = [21 x i8] c"%2d\E9\80\B2\E6\95\B0\E8\A1\A8\E8\A8\98: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [256 x i8]
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = icmp ne i32 %6, 1
br i1 %7, label %8, label %9
8: ; preds = %0
store i32 1, i32* %1
br label %28
9: ; preds = %0
store i32 2, i32* %4
br label %10
10: ; preds = %24, %9
%11 = load i32, i32* %4
%12 = icmp sle i32 %11, 16
br i1 %12, label %13, label %27
13: ; preds = %10
%14 = load i32, i32* %2
%15 = load i32, i32* %4
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%17 = call i64 @base_convert(i32 %14, i32 %15, i32 256, i8* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %13
%20 = load i32, i32* %4
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %20, i8* %21)
br label %23
23: ; preds = %19, %13
br label %24
24: ; preds = %23
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %10
27: ; preds = %10
store i32 0, i32* %1
br label %28
28: ; preds = %27, %8
%29 = load i32, i32* %1
ret i32 %29
}

LLVM IR (-O2):
@.str = [30 x i8] c"0\E4\BB\A5\E4\B8\8A\E3\81\AE10\E9\80\B2\E6\95\B0\E3\82\92\E5\85\A5\E5\8A\9B: \00"
@.str.1 = [3 x i8] c"%u\00"
@.str.2 = [21 x i8] c"%2d\E9\80\B2\E6\95\B0\E8\A1\A8\E8\A8\98: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %18
8: ; preds = %0, %15
%9 = phi i32 [ %16, %15 ], [ 2, %0 ]
%10 = load i32, i32* %1
%11 = call i64 @base_convert(i32 %10, i32 %9, i32 256, i8* %4)
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %8
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %9, i8* %4)
br label %15
15: ; preds = %8, %13
%16 = add nuw nsw i32 %9, 1
%17 = icmp eq i32 %16, 17
br i1 %17, label %18, label %8
18: ; preds = %15, %0
%19 = phi i32 [ 1, %0 ], [ 0, %15 ]
ret i32 %19
}