#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 */
char *application_background_color(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int strlen(char *);
void document_output_body_stream(FILE *output_stream, char *application_name,
                                 char *onload_control_string) {
  fprintf(output_stream, "<body");
  fprintf(output_stream, " bgcolor=%s",
          application_background_color(application_name));
  if (onload_control_string && *onload_control_string) {
    int str_len;
    fprintf(output_stream, " onload=\"%s", onload_control_string);
    str_len = strlen(onload_control_string);
    if (*(onload_control_string + str_len) != ';')
      fprintf(output_stream, ";");
    fprintf(output_stream, "\"");
  }
  fprintf(output_stream, ">\n");
}


x86 assembly (clang, -O0):
<document_output_body_stream>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb1(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <application_background_color@plt>
mov    -0x28(%rbp),%rdi
mov    %rax,%rdx
lea    0xe91(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
cmpq   $0x0,-0x18(%rbp)
je     11f2 <document_output_body_stream+0xc2>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11f2 <document_output_body_stream+0xc2>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe6c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3b,%eax
je     11e0 <document_output_body_stream+0xb0>
mov    -0x8(%rbp),%rdi
lea    0xe45(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe35(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe25(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<document_output_body_stream>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0xe9b(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1070 <fwrite@plt>
mov    %rbx,%rdi
call   1030 <application_background_color@plt>
lea    0xe80(%rip),%rsi
mov    %r15,%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
test   %r14,%r14
je     11dd <document_output_body_stream+0x8d>
cmpb   $0x0,(%r14)
je     11dd <document_output_body_stream+0x8d>
lea    0xe6d(%rip),%rsi
mov    %r15,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0x3b,(%r14,%rax,1)
je     11d0 <document_output_body_stream+0x80>
mov    $0x3b,%edi
mov    %r15,%rsi
call   1050 <fputc@plt>
mov    $0x22,%edi
mov    %r15,%rsi
call   1050 <fputc@plt>
lea    0xe3a(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r15,%rcx
pop    %rbx
pop    %r14
pop    %r15
jmp    1070 <fwrite@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"<body\00"
@.str.1 = [12 x i8] c" bgcolor=%s\00"
@.str.2 = [12 x i8] c" onload=\22%s\00"
@.str.3 = [2 x i8] c";\00"
@.str.4 = [2 x i8] c"\22\00"
@.str.5 = [3 x i8] c">\0A\00"
define void @document_output_body_stream(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = load i32*, i32** %4
%9 = call i32 (i32*, i8*, ...) @fprintf(i32* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%10 = load i32*, i32** %4
%11 = load i8*, i8** %5
%12 = call i8* @application_background_color(i8* %11)
%13 = call i32 (i32*, i8*, ...) @fprintf(i32* %10, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = load i8*, i8** %6
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %40
16: ; preds = %3
%17 = load i8*, i8** %6
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %40
21: ; preds = %16
%22 = load i32*, i32** %4
%23 = load i8*, i8** %6
%24 = call i32 (i32*, i8*, ...) @fprintf(i32* %22, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%25 = load i8*, i8** %6
%26 = call i32 @strlen(i8* %25)
store i32 %26, i32* %7
%27 = load i8*, i8** %6
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 59
br i1 %33, label %34, label %37
34: ; preds = %21
%35 = load i32*, i32** %4
%36 = call i32 (i32*, i8*, ...) @fprintf(i32* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %37
37: ; preds = %34, %21
%38 = load i32*, i32** %4
%39 = call i32 (i32*, i8*, ...) @fprintf(i32* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %40
40: ; preds = %37, %16, %3
%41 = load i32*, i32** %4
%42 = call i32 (i32*, i8*, ...) @fprintf(i32* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"<body\00"
@.str.1 = [12 x i8] c" bgcolor=%s\00"
@.str.2 = [12 x i8] c" onload=\22%s\00"
@.str.5 = [3 x i8] c">\0A\00"
define void @document_output_body_stream(i32* nocapture %0, i8* %1, i8* %2) {
%4 = tail call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 5, i64 1, i32* %0)
%5 = tail call i8* @application_background_color(i8* %1)
%6 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%7 = icmp eq i8* %2, null
br i1 %7, label %22, label %8
8: ; preds = %3
%9 = load i8, i8* %2
%10 = icmp eq i8 %9, 0
br i1 %10, label %22, label %11
11: ; preds = %8
%12 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%13 = tail call i32 @strlen(i8* %2)
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %2, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 59
br i1 %17, label %20, label %18
18: ; preds = %11
%19 = tail call i32 @fputc(i32 59, i32* %0)
br label %20
20: ; preds = %18, %11
%21 = tail call i32 @fputc(i32 34, i32* %0)
br label %22
22: ; preds = %20, %8, %3
%23 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i64 2, i64 1, i32* %0)
ret void
}