#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 fdprintf(int, char *, char *);
int write(int, char *, int);
int http_print_lines(char **list, int fd, int n) {
  int i;
  for (i = 0; i < n; i++)
    if (list[i])
      if (fdprintf(fd, "%s\r\n", list[i]) == -1)
        return 1;
  if (write(fd, "\r\n", 2) != 2)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<http_print_lines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11a0 <http_print_lines+0x80>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     118d <http_print_lines+0x6d>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe92(%rip),%rsi
call   1040 <fdprintf@plt>
cmp    $0xffffffff,%eax
jne    1188 <http_print_lines+0x68>
movl   $0x1,-0x4(%rbp)
jmp    11d0 <http_print_lines+0xb0>
jmp    118d <http_print_lines+0x6d>
jmp    1192 <http_print_lines+0x72>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1139 <http_print_lines+0x19>
mov    -0x14(%rbp),%edi
lea    0xe58(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
cmp    $0x2,%eax
je     11c9 <http_print_lines+0xa9>
movl   $0x1,-0x4(%rbp)
jmp    11d0 <http_print_lines+0xb0>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<http_print_lines>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r15d
test   %edx,%edx
jle    1169 <http_print_lines+0x49>
mov    %rdi,%r12
mov    %edx,%ebp
xor    %ebx,%ebx
lea    0xec3(%rip),%r14
jmp    1149 <http_print_lines+0x29>
nop
add    $0x1,%rbx
cmp    %rbx,%rbp
je     1169 <http_print_lines+0x49>
mov    (%r12,%rbx,8),%rdx
test   %rdx,%rdx
je     1140 <http_print_lines+0x20>
mov    %r15d,%edi
mov    %r14,%rsi
call   1040 <fdprintf@plt>
cmp    $0xffffffff,%eax
jne    1140 <http_print_lines+0x20>
mov    $0x1,%eax
jmp    1187 <http_print_lines+0x67>
lea    0xe92(%rip),%rsi
mov    %r15d,%edi
mov    $0x2,%edx
call   1030 <write@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x2,%ecx
setne  %al
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"%s\0D\0A\00"
@.str.1 = [3 x i8] c"\0D\0A\00"
define i32 @http_print_lines(i8** nocapture %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %18
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %7
7: ; preds = %5, %15
%8 = phi i64 [ 0, %5 ], [ %16, %15 ]
%9 = getelementptr inbounds i8*, i8** %0, i64 %8
%10 = load i8*, i8** %9
%11 = icmp eq i8* %10, null
br i1 %11, label %15, label %12
12: ; preds = %7
%13 = tail call i32 @fdprintf(i32 %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %10)
%14 = icmp eq i32 %13, -1
br i1 %14, label %22, label %15
15: ; preds = %7, %12
%16 = add nuw nsw i64 %8, 1
%17 = icmp eq i64 %16, %6
br i1 %17, label %18, label %7
18: ; preds = %15, %3
%19 = tail call i32 @write(i32 %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%20 = icmp ne i32 %19, 2
%21 = zext i1 %20 to i32
br label %22
22: ; preds = %12, %18
%23 = phi i32 [ %21, %18 ], [ 1, %12 ]
ret i32 %23
}