#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
char *strchr(char *, char);
void disp_html(char *fnam, char *msg) {
  FILE *fp;
  char buf[512], *p;
  if ((fp = fopen(fnam, "r")) == NULL) {
    fprintf(stderr, "What can I do ??\n");
    return;
  }
  while (fgets(buf, 512, fp) != NULL) {
    if ((p = strchr(buf, '%')) != NULL) {
      if (*(p + 1) == 's') {
        printf(buf, msg);
        continue;
      }
    }
    printf("%s", buf);
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<disp_html>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe82(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11ab <disp_html+0x4b>
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
lea    0xe61(%rip),%rsi
call   1070 <fprintf@plt>
jmp    1240 <disp_html+0xe0>
jmp    11b0 <disp_html+0x50>
lea    -0x220(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x200,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1237 <disp_html+0xd7>
lea    -0x220(%rbp),%rdi
mov    $0x25,%esi
call   1040 <strchr@plt>
mov    %rax,-0x228(%rbp)
cmp    $0x0,%rax
je     121f <disp_html+0xbf>
mov    -0x228(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x73,%eax
jne    121a <disp_html+0xba>
lea    -0x220(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <printf@plt>
jmp    11b0 <disp_html+0x50>
jmp    121f <disp_html+0xbf>
lea    -0x220(%rbp),%rsi
lea    0xde7(%rip),%rdi
call   1050 <printf@plt>
jmp    11b0 <disp_html+0x50>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<disp_html>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    %rsi,%r14
lea    0xe88(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1207 <disp_html+0xa7>
mov    %rax,%r15
mov    %rsp,%rdi
mov    $0x200,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11f0 <disp_html+0x90>
mov    %rsp,%rbx
lea    0xe6c(%rip),%r12
jmp    11d0 <disp_html+0x70>
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x200,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11f0 <disp_html+0x90>
mov    %rbx,%rdi
mov    $0x25,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11b0 <disp_html+0x50>
cmpb   $0x73,0x1(%rax)
jne    11b0 <disp_html+0x50>
mov    %rbx,%rdi
mov    %r14,%rsi
jmp    11b6 <disp_html+0x56>
mov    %r15,%rdi
call   1030 <fclose@plt>
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
lea    0xdeb(%rip),%rsi
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1070 <fprintf@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [18 x i8] c"What can I do ??\0A\00"
@.str.2 = [3 x i8] c"%s\00"
define void @disp_html(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca [512 x i8]
%7 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %3
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %5
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %41
14: ; preds = %2
br label %15
15: ; preds = %35, %30, %14
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%17 = load i32*, i32** %5
%18 = call i32* @fgets(i8* %16, i32 512, i32* %17)
%19 = icmp ne i32* %18, null
br i1 %19, label %20, label %38
20: ; preds = %15
%21 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%22 = call i8* @strchr(i8* %21, i8 signext 37)
store i8* %22, i8** %7
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %35
24: ; preds = %20
%25 = load i8*, i8** %7
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 115
br i1 %29, label %30, label %34
30: ; preds = %24
%31 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%32 = load i8*, i8** %4
%33 = call i32 @printf(i8* %31, i8* %32)
br label %15
34: ; preds = %24
br label %35
35: ; preds = %34, %20
%36 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%37 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %36)
br label %15
38: ; preds = %15
%39 = load i32*, i32** %5
%40 = call i32 @fclose(i32* %39)
br label %41
41: ; preds = %38, %11
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [18 x i8] c"What can I do ??\0A\00"
@.str.2 = [3 x i8] c"%s\00"
define void @disp_html(i8* nocapture %0, i8* %1) {
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = call i32* @fgets(i8* %4, i32 512, i32* %5)
%9 = icmp eq i32* %8, null
br i1 %9, label %27, label %13
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %29
13: ; preds = %7, %22
%14 = call i8* @strchr(i8* %4, i8 signext 37)
%15 = icmp eq i8* %14, null
br i1 %15, label %25, label %16
16: ; preds = %13
%17 = getelementptr inbounds i8, i8* %14, i64 1
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 115
br i1 %19, label %20, label %25
20: ; preds = %16
%21 = call i32 @printf(i8* %4, i8* %1)
br label %22
22: ; preds = %20, %25
%23 = call i32* @fgets(i8* %4, i32 512, i32* %5)
%24 = icmp eq i32* %23, null
br i1 %24, label %27, label %13
25: ; preds = %16, %13
%26 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %4)
br label %22
27: ; preds = %22, %7
%28 = call i32 @fclose(i32* %5)
br label %29
29: ; preds = %27, %10
ret void
}