#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 */
char *http_status_get_status_text(int);
int snprintf(char *, size_t, char *, int, ...);
int http_status_format_line(int code, char *buff, size_t len) {
  int result;
  const char *text = http_status_get_status_text(code);
  if (text) {
    result = snprintf(buff, len, "%d %s", code, text);
  } else {
    result = snprintf(buff, len, "%d", code);
  }
  return result;
}


x86 assembly (clang, -O0):
<http_status_format_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <http_status_get_status_text@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     116f <http_status_format_line+0x4f>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x4(%rbp),%ecx
mov    -0x28(%rbp),%r8
lea    0xea0(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,-0x1c(%rbp)
jmp    118b <http_status_format_line+0x6b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x4(%rbp),%ecx
lea    0xe85(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<http_status_format_line>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%ebx
call   1040 <http_status_get_status_text@plt>
test   %rax,%rax
je     1155 <http_status_format_line+0x35>
lea    0xec2(%rip),%rdx
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebx,%ecx
mov    %rax,%r8
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <snprintf@plt>
lea    0xeaa(%rip),%rdx
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebx,%ecx
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <snprintf@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"%d %s\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @http_status_format_line(i32 %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%9 = load i32, i32* %4
%10 = call i8* @http_status_get_status_text(i32 %9)
store i8* %10, i8** %8
%11 = load i8*, i8** %8
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %19
13: ; preds = %3
%14 = load i8*, i8** %5
%15 = load i64, i64* %6
%16 = load i32, i32* %4
%17 = load i8*, i8** %8
%18 = call i32 (i8*, i64, i8*, i32, ...) @snprintf(i8* %14, i64 %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %16, i8* %17)
store i32 %18, i32* %7
br label %24
19: ; preds = %3
%20 = load i8*, i8** %5
%21 = load i64, i64* %6
%22 = load i32, i32* %4
%23 = call i32 (i8*, i64, i8*, i32, ...) @snprintf(i8* %20, i64 %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %22)
store i32 %23, i32* %7
br label %24
24: ; preds = %19, %13
%25 = load i32, i32* %7
ret i32 %25
}

LLVM IR (-O2):
@.str = [6 x i8] c"%d %s\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @http_status_format_line(i32 %0, i8* %1, i64 %2) {
%4 = tail call i8* @http_status_get_status_text(i32 %0)
%5 = icmp eq i8* %4, null
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call i32 (i8*, i64, i8*, i32, ...) @snprintf(i8* %1, i64 %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %0, i8* %4)
br label %10
8: ; preds = %3
%9 = tail call i32 (i8*, i64, i8*, i32, ...) @snprintf(i8* %1, i64 %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %0)
br label %10
10: ; preds = %8, %6
%11 = phi i32 [ %7, %6 ], [ %9, %8 ]
ret i32 %11
}