#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*/ sprintf(char *, char *, char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main() {
  char opname[10];
  char buffer[80];
  unsigned A = 0xA6;
  printf("A: %#08x\n", A);
  printf("Percent sign: %%\n");
  strcpy(opname, "addcc");
  sprintf(buffer, "The string '%s' contains %d characters\n", opname,
          strlen(opname));
  printf("%s", buffer);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa6,-0x64(%rbp)
mov    -0x64(%rbp),%esi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xe(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x60(%rbp),%rax
mov    %rax,-0x78(%rbp)
lea    -0xe(%rbp),%rax
mov    %rax,-0x70(%rbp)
lea    -0xe(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x78(%rbp),%rdi
mov    -0x70(%rbp),%rdx
mov    %eax,%ecx
lea    0xe70(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x60(%rbp),%rsi
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x68,%rsp
lea    0xeb2(%rip),%rdi
mov    $0xa6,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea9(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xead(%rip),%rsi
lea    0x6(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0xe97(%rip),%rsi
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rdx
mov    %eax,%ecx
call   1060 <sprintf@plt>
lea    0xea6(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [10 x i8] c"A: %x\0A\00"
@.str.1 = [18 x i8] c"Percent sign: %%\0A\00"
@.str.2 = [6 x i8] c"addcc\00"
@.str.3 = [40 x i8] c"The string '%s' contains %d characters\0A\00"
@.str.4 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca [80 x i8]
%4 = alloca i32
store i32 0, i32* %1
store i32 166, i32* %4
%5 = load i32, i32* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%9 = call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%13 = call i32 @strlen(i8* %12)
%14 = call i32 @sprintf(i8* %10, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i8* %11, i32 %13)
%15 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %15)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"A: %x\0A\00"
@.str.1 = [18 x i8] c"Percent sign: %%\0A\00"
@.str.2 = [6 x i8] c"addcc\00"
@.str.3 = [40 x i8] c"The string '%s' contains %d characters\0A\00"
@.str.4 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = alloca [80 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 166)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @strlen(i8* %3)
%9 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i8* %3, i32 %8)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %4)
ret i32 0
}