#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_d(char *, int);
int /*<<< orphan*/ printf_s(char *, char const *);
char *Format(const char *fmt, ...) {
  char buf[200];
  int *a = (int *)&fmt;
  printf_s("format: %s\r", fmt);
  printf_d("  arg1: %s\r", a[1]);
  printf_d("  arg2: %s\r", a[2]);
  printf_d("  arg3: %s\r", a[3]);
  return 0;
}


x86 assembly (clang, -O0):
<Format>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0xd8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xebb(%rip),%rdi
call   1030 <printf_s@plt>
mov    -0xd8(%rbp),%rax
mov    0x4(%rax),%esi
lea    0xeb1(%rip),%rdi
call   1040 <printf_d@plt>
mov    -0xd8(%rbp),%rax
mov    0x8(%rax),%esi
lea    0xea7(%rip),%rdi
call   1040 <printf_d@plt>
mov    -0xd8(%rbp),%rax
mov    0xc(%rax),%esi
lea    0xe9d(%rip),%rdi
call   1040 <printf_d@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Format>:
push   %rbx
mov    %rdi,%rbx
lea    0xed5(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf_s@plt>
shr    $0x20,%rbx
lea    0xece(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf_d@plt>
lea    0xecc(%rip),%rdi
call   1040 <printf_d@plt>
lea    0xecc(%rip),%rdi
call   1040 <printf_d@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"format: %s\0D\00"
@.str.1 = [12 x i8] c" arg1: %s\0D\00"
@.str.2 = [12 x i8] c" arg2: %s\0D\00"
@.str.3 = [12 x i8] c" arg3: %s\0D\00"
define i8* @Format(i8* %0, ...) {
%2 = alloca i8*
%3 = alloca [200 x i8]
%4 = alloca i32*
store i8* %0, i8** %2
%5 = bitcast i8** %2 to i32*
store i32* %5, i32** %4
%6 = load i8*, i8** %2
%7 = call i32 @printf_s(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32*, i32** %4
%9 = getelementptr inbounds i32, i32* %8, i64 1
%10 = load i32, i32* %9
%11 = call i32 @printf_d(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = load i32*, i32** %4
%13 = getelementptr inbounds i32, i32* %12, i64 2
%14 = load i32, i32* %13
%15 = call i32 @printf_d(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%16 = load i32*, i32** %4
%17 = getelementptr inbounds i32, i32* %16, i64 3
%18 = load i32, i32* %17
%19 = call i32 @printf_d(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %18)
ret i8* null
}

LLVM IR (-O2):
@.str = [12 x i8] c"format: %s\0D\00"
@.str.1 = [12 x i8] c" arg1: %s\0D\00"
@.str.2 = [12 x i8] c" arg2: %s\0D\00"
@.str.3 = [12 x i8] c" arg3: %s\0D\00"
define noalias i8* @Format(i8* %0, ...) {
%2 = tail call i32 @printf_s(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = ptrtoint i8* %0 to i64
%4 = lshr i64 %3, 32
%5 = trunc i64 %4 to i32
%6 = tail call i32 @printf_d(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = tail call i32 @printf_d(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 poison)
%8 = tail call i32 @printf_d(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 poison)
ret i8* null
}