#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 /*<<< orphan*/ romanize(unsigned int, char *);
int scanf(char *, unsigned int *);
int main(void) {
  char buffer[16];
  unsigned input;
  printf("1〜3999までの数値を入力: ");
  if (scanf("%u", &input) != 1) {
    printf("読み取りに失敗しました\n");
    return 1;
  }
  if (!romanize(input, buffer)) {
    printf("%u は表記できません\n", input);
    return 1;
  }
  printf("%u はローマ数字表記で %s です\n", input, buffer);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
je     1180 <main+0x50>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11ce <main+0x9e>
mov    -0x24(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1050 <romanize@plt>
cmp    $0x0,%eax
jne    11b2 <main+0x82>
mov    -0x24(%rbp),%esi
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11ce <main+0x9e>
mov    -0x24(%rbp),%esi
lea    -0x20(%rbp),%rdx
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec9(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    1196 <main+0x56>
mov    0xc(%rsp),%edi
lea    0x10(%rsp),%rsi
call   1060 <romanize@plt>
mov    0xc(%rsp),%esi
test   %eax,%eax
je     11a4 <main+0x64>
lea    0xebd(%rip),%rdi
xor    %ebx,%ebx
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11b7 <main+0x77>
lea    0xed0(%rip),%rdi
call   1030 <puts@plt>
jmp    11b2 <main+0x72>
lea    0xe7b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [35 x i8] c"1\E3\80\9C3999\E3\81\BE\E3\81\A7\E3\81\AE\E6\95\B0\E5\80\A4\E3\82\92\E5\85\A5\E5\8A\9B: \00"
@.str.1 = [3 x i8] c"%u\00"
@.str.2 = [35 x i8] c"\E8\AA\AD\E3\81\BF\E5\8F\96\E3\82\8A\E3\81\AB\E5\A4\B1\E6\95\97\E3\81\97\E3\81\BE\E3\81\97\E3\81\9F\0A\00"
@.str.3 = [29 x i8] c"%u \E3\81\AF\E8\A1\A8\E8\A8\98\E3\81\A7\E3\81\8D\E3\81\BE\E3\81\9B\E3\82\93\0A\00"
@.str.4 = [42 x i8] c"%u \E3\81\AF\E3\83\AD\E3\83\BC\E3\83\9E\E6\95\B0\E5\AD\97\E8\A1\A8\E8\A8\98\E3\81\A7 %s \E3\81\A7\E3\81\99\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [16 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%6 = icmp ne i32 %5, 1
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %21
9: ; preds = %0
%10 = load i32, i32* %3
%11 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%12 = call i32 @romanize(i32 %10, i8* %11)
%13 = icmp ne i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %9
%15 = load i32, i32* %3
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %15)
store i32 1, i32* %1
br label %21
17: ; preds = %9
%18 = load i32, i32* %3
%19 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i32 %18, i8* %19)
store i32 0, i32* %1
br label %21
21: ; preds = %17, %14, %7
%22 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
@.str = [35 x i8] c"1\E3\80\9C3999\E3\81\BE\E3\81\A7\E3\81\AE\E6\95\B0\E5\80\A4\E3\82\92\E5\85\A5\E5\8A\9B: \00"
@.str.1 = [3 x i8] c"%u\00"
@.str.3 = [29 x i8] c"%u \E3\81\AF\E8\A1\A8\E8\A8\98\E3\81\A7\E3\81\8D\E3\81\BE\E3\81\9B\E3\82\93\0A\00"
@.str.4 = [42 x i8] c"%u \E3\81\AF\E3\83\AD\E3\83\BC\E3\83\9E\E6\95\B0\E5\AD\97\E8\A1\A8\E8\A8\98\E3\81\A7 %s \E3\81\A7\E3\81\99\0A\00"
@str = [34 x i8] c"\E8\AA\AD\E3\81\BF\E5\8F\96\E3\82\8A\E3\81\AB\E5\A4\B1\E6\95\97\E3\81\97\E3\81\BE\E3\81\97\E3\81\9F\00"
define i32 @main() {
%1 = alloca [16 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 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 eq i32 %6, 1
br i1 %7, label %10, label %8
8: ; preds = %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
br label %19
10: ; preds = %0
%11 = load i32, i32* %2
%12 = call i32 @romanize(i32 %11, i8* %3)
%13 = icmp eq i32 %12, 0
%14 = load i32, i32* %2
br i1 %13, label %15, label %17
15: ; preds = %10
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %14)
br label %19
17: ; preds = %10
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i32 %14, i8* %3)
br label %19
19: ; preds = %17, %15, %8
%20 = phi i32 [ 1, %8 ], [ 0, %17 ], [ 1, %15 ]
ret i32 %20
}