#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*/ free(char *);
int /*<<< orphan*/ printf(char *, ...);
char *tpl_peek(int, char *, char *, char *);
int main() {
  char *fmt, c;
  fmt = tpl_peek((1 << 0) | (1 << 6), "test99.tpl", "c", &c);
  if (fmt) {
    printf("%s\n", fmt);
    free(fmt);
    printf("%c\n", c);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x41,%edi
lea    0xeb5(%rip),%rsi
lea    0xeb9(%rip),%rdx
lea    -0x11(%rbp),%rcx
call   1050 <tpl_peek@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1197 <main+0x67>
mov    -0x10(%rbp),%rsi
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movsbl -0x11(%rbp),%esi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb4(%rip),%rsi
lea    0xeb8(%rip),%rdx
lea    0xf(%rsp),%rcx
mov    $0x41,%edi
call   1060 <tpl_peek@plt>
test   %rax,%rax
je     118d <main+0x4d>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
movsbl 0xf(%rsp),%esi
lea    0xe87(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"test99.tpl\00"
@.str.1 = [2 x i8] c"c\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [4 x i8] c"%c\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8
store i32 0, i32* %1
%4 = call i8* @tpl_peek(i32 65, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %3)
store i8* %4, i8** %2
%5 = load i8*, i8** %2
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %15
7: ; preds = %0
%8 = load i8*, i8** %2
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%10 = load i8*, i8** %2
%11 = call i32 @free(i8* %10)
%12 = load i8, i8* %3
%13 = sext i8 %12 to i32
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %7, %0
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"test99.tpl\00"
@.str.1 = [2 x i8] c"c\00"
@.str.3 = [4 x i8] c"%c\0A\00"
define i32 @main() {
%1 = alloca i8
%2 = call i8* @tpl_peek(i32 65, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%3 = icmp eq i8* %2, null
br i1 %3, label %10, label %4
4: ; preds = %0
%5 = call i32 @puts(i8* %2)
%6 = call i32 @free(i8* %2)
%7 = load i8, i8* %1
%8 = sext i8 %7 to i32
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %8)
br label %10
10: ; preds = %4, %0
ret i32 0
}