#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 */
struct mg_request_info {
  int dummy;
};
struct mg_connection {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ mg_printf(struct mg_connection *, char *, char const *);
void show_huge(struct mg_connection *conn,
               const struct mg_request_info *request_info, void *user_data) {
  int i;
  const char *line = "Hello, this is a line of text";
  mg_printf(conn, "%s", "HTTP/1.1 200 OK\r\n");
  mg_printf(conn, "%s", "Content-Type: text/plain\r\n\r\n");
  for (i = 0; i < 1024 * 1024; i++)
    mg_printf(conn, "%s\n", line);
}


x86 assembly (clang, -O0):
<show_huge>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xed5(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xee4(%rip),%rsi
lea    0xee0(%rip),%rdx
call   1030 <mg_printf@plt>
mov    -0x8(%rbp),%rdi
lea    0xecd(%rip),%rsi
lea    0xedb(%rip),%rdx
call   1030 <mg_printf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x100000,-0x1c(%rbp)
jge    1193 <show_huge+0x83>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xed0(%rip),%rsi
call   1030 <mg_printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1164 <show_huge+0x54>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_huge>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xefd(%rip),%r14
lea    0xef9(%rip),%rdx
mov    %r14,%rsi
call   1030 <mg_printf@plt>
lea    0xefc(%rip),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <mg_printf@plt>
mov    $0x100000,%ebp
lea    0xf02(%rip),%r14
lea    0xeab(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <mg_printf@plt>
add    $0xffffffff,%ebp
jne    1160 <show_huge+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.mg_connection = type { i32 }
%struct.mg_request_info = type { i32 }
@.str = [30 x i8] c"Hello, this is a line of text\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [18 x i8] c"HTTP/1.1 200 OK\0D\0A\00"
@.str.3 = [29 x i8] c"Content-Type: text/plain\0D\0A\0D\0A\00"
@.str.4 = [4 x i8] c"%s\0A\00"
define void @show_huge(%struct.mg_connection* %0, %struct.mg_request_info* %1, i8* %2) {
%4 = alloca %struct.mg_connection*
%5 = alloca %struct.mg_request_info*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
store %struct.mg_connection* %0, %struct.mg_connection** %4
store %struct.mg_request_info* %1, %struct.mg_request_info** %5
store i8* %2, i8** %6
store i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8** %8
%9 = load %struct.mg_connection*, %struct.mg_connection** %4
%10 = call i32 @mg_printf(%struct.mg_connection* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%11 = load %struct.mg_connection*, %struct.mg_connection** %4
%12 = call i32 @mg_printf(%struct.mg_connection* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %7
br label %13
13: ; preds = %20, %3
%14 = load i32, i32* %7
%15 = icmp slt i32 %14, 1048576
br i1 %15, label %16, label %23
16: ; preds = %13
%17 = load %struct.mg_connection*, %struct.mg_connection** %4
%18 = load i8*, i8** %8
%19 = call i32 @mg_printf(%struct.mg_connection* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %16
%21 = load i32, i32* %7
%22 = add nsw i32 %21, 1
store i32 %22, i32* %7
br label %13
23: ; preds = %13
ret void
}

LLVM IR (-O2):
%struct.mg_connection = type { i32 }
%struct.mg_request_info = type { i32 }
@.str = [30 x i8] c"Hello, this is a line of text\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [18 x i8] c"HTTP/1.1 200 OK\0D\0A\00"
@.str.3 = [29 x i8] c"Content-Type: text/plain\0D\0A\0D\0A\00"
@.str.4 = [4 x i8] c"%s\0A\00"
define void @show_huge(%struct.mg_connection* %0, %struct.mg_request_info* nocapture readnone %1, i8* nocapture readnone %2) {
%4 = tail call i32 @mg_printf(%struct.mg_connection* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i32 @mg_printf(%struct.mg_connection* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
br label %6
6: ; preds = %3, %6
%7 = phi i32 [ 0, %3 ], [ %9, %6 ]
%8 = tail call i32 @mg_printf(%struct.mg_connection* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%9 = add nuw nsw i32 %7, 1
%10 = icmp eq i32 %9, 1048576
br i1 %10, label %11, label %6
11: ; preds = %6
ret void
}