#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int const UINT8_MAX;
int atoi(char const *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char const **argv) {
  if (2 != argc) {
    fprintf(stderr, "Usage: putc <decimal-ascii-code>\n");
    return EXIT_FAILURE;
  }
  char const *decimal_ascii_code = argv[1];
  int const ascii_code = atoi(decimal_ascii_code);
  if ((ascii_code < 0) || (ascii_code > UINT8_MAX)) {
    fprintf(stderr, "Invalid ascii code %d\n", ascii_code);
    return EXIT_FAILURE;
  }
  fprintf(stdout, "%c", ascii_code);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x2,%eax
cmp    -0x8(%rbp),%eax
je     116c <main+0x4c>
mov    0x2e95(%rip),%rax
mov    (%rax),%edi
lea    0xeac(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e76(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11f1 <main+0xd1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jl     11a0 <main+0x80>
mov    -0x1c(%rbp),%eax
mov    0x2e28(%rip),%rcx
cmp    (%rcx),%eax
jle    11cb <main+0xab>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
lea    0xe6f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e17(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11f1 <main+0xd1>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
lea    0xe5b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2ddc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x2,%edi
jne    1155 <main+0x35>
mov    0x8(%rsi),%rdi
call   1040 <atoi@plt>
test   %eax,%eax
je     1175 <main+0x55>
mov    0x2ea6(%rip),%rcx
mov    (%rcx),%edi
lea    0xedf(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x2e85(%rip),%rax
jmp    1195 <main+0x75>
mov    0x2e84(%rip),%rax
mov    (%rax),%edi
lea    0xe9b(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x2e65(%rip),%rax
jmp    1195 <main+0x75>
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
lea    0xeb4(%rip),%rsi
xor    %edx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x2e33(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"Usage: putc <decimal-ascii-code>\0A\00"
@EXIT_FAILURE = global i32 0
@UINT8_MAX = constant i32 0
@.str.1 = [23 x i8] c"Invalid ascii code %d\0A\00"
@stdout = global i32 0
@.str.2 = [3 x i8] c"%c\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 2, %8
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
store i32 %13, i32* %3
br label %36
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
store i8* %17, i8** %6
%18 = load i8*, i8** %6
%19 = call i32 @atoi(i8* %18)
store i32 %19, i32* %7
%20 = load i32, i32* %7
%21 = icmp slt i32 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %14
%23 = load i32, i32* %7
%24 = load i32, i32* @UINT8_MAX
%25 = icmp sgt i32 %23, %24
br i1 %25, label %26, label %31
26: ; preds = %22, %14
%27 = load i32, i32* @stderr
%28 = load i32, i32* %7
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = load i32, i32* @EXIT_FAILURE
store i32 %30, i32* %3
br label %36
31: ; preds = %22
%32 = load i32, i32* @stdout
%33 = load i32, i32* %7
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = load i32, i32* @EXIT_SUCCESS
store i32 %35, i32* %3
br label %36
36: ; preds = %31, %26, %10
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"Usage: putc <decimal-ascii-code>\0A\00"
@EXIT_FAILURE = global i32 0
@UINT8_MAX = constant i32 0
@.str.1 = [23 x i8] c"Invalid ascii code %d\0A\00"
@stdout = global i32 0
@.str.2 = [3 x i8] c"%c\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %18
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %7
%13 = load i32, i32* @stderr
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %10)
br label %18
15: ; preds = %7
%16 = load i32, i32* @stdout
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 0)
br label %18
18: ; preds = %12, %15, %4
%19 = phi i32* [ @EXIT_FAILURE, %4 ], [ @EXIT_FAILURE, %12 ], [ @EXIT_SUCCESS, %15 ]
%20 = load i32, i32* %19
ret i32 %20
}