#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 sendString(char *);
int /*<<< orphan*/ sprintf(char *, char *, int, int);
int /*<<< orphan*/ strcpy(char *, char *);
int sendHeaderField(int size, int type) {
  int temp = -10;
  char headerField[64 + 1];
  strcpy(headerField, "Content-length: ");
  sprintf(&headerField[16], "%*d", size, 15);
  headerField[31] = ';';
  strcpy(&headerField[32], "Content-type: ");
  switch (type) {
  case 0:
    strcpy(&headerField[46], "ObjectBid");
    break;
  case 1:
    strcpy(&headerField[46], "UserAccount");
    break;
  default:
    temp = -22;
    break;
  }
  headerField[62] = ';';
  headerField[63] = '\n';
  headerField[64] = '\0';
  if (temp == -10)
    temp = sendString(headerField);
  return temp;
}


x86 assembly (clang, -O0):
<sendHeaderField>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0xfffffff6,-0xc(%rbp)
lea    0xeb4(%rip),%rsi
lea    -0x50(%rbp),%rdi
call   1040 <strcpy@plt>
lea    -0x40(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xeae(%rip),%rsi
mov    $0xf,%ecx
call   1050 <sprintf@plt>
movb   $0x3b,-0x31(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x54(%rbp)
test   %eax,%eax
je     11a5 <sendHeaderField+0x75>
jmp    1194 <sendHeaderField+0x64>
mov    -0x54(%rbp),%eax
sub    $0x1,%eax
je     11be <sendHeaderField+0x8e>
jmp    11d7 <sendHeaderField+0xa7>
lea    -0x50(%rbp),%rdi
add    $0x2e,%rdi
lea    0xe70(%rip),%rsi
call   1040 <strcpy@plt>
jmp    11de <sendHeaderField+0xae>
lea    -0x50(%rbp),%rdi
add    $0x2e,%rdi
lea    0xe61(%rip),%rsi
call   1040 <strcpy@plt>
jmp    11de <sendHeaderField+0xae>
movl   $0xffffffea,-0xc(%rbp)
movb   $0x3b,-0x12(%rbp)
movb   $0xa,-0x11(%rbp)
movb   $0x0,-0x10(%rbp)
cmpl   $0xfffffff6,-0xc(%rbp)
jne    1200 <sendHeaderField+0xd0>
lea    -0x50(%rbp),%rdi
call   1030 <sendString@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendHeaderField>:
push   %rbp
push   %rbx
sub    $0x48,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
lea    0xebf(%rip),%rsi
mov    %rsp,%rdi
call   1040 <strcpy@plt>
lea    0x10(%rsp),%rdi
lea    0xebc(%rip),%rsi
mov    %ebp,%edx
mov    $0xf,%ecx
call   1050 <sprintf@plt>
movb   $0x3b,0x1f(%rsp)
lea    0x20(%rsp),%rdi
lea    0xea3(%rip),%rsi
call   1040 <strcpy@plt>
test   %ebx,%ebx
je     118e <sendHeaderField+0x5e>
mov    $0xffffffea,%eax
cmp    $0x1,%ebx
jne    11b3 <sendHeaderField+0x83>
lea    0xea2(%rip),%rsi
jmp    1195 <sendHeaderField+0x65>
lea    0xe8f(%rip),%rsi
lea    0x2e(%rsp),%rdi
call   1040 <strcpy@plt>
movw   $0xa3b,0x3e(%rsp)
movb   $0x0,0x40(%rsp)
mov    %rsp,%rdi
call   1030 <sendString@plt>
add    $0x48,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Content-length: \00"
@.str.1 = [4 x i8] c"%*d\00"
@.str.2 = [15 x i8] c"Content-type: \00"
@.str.3 = [10 x i8] c"ObjectBid\00"
@.str.4 = [12 x i8] c"UserAccount\00"
define i32 @sendHeaderField(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [65 x i8]
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 -10, i32* %5
%7 = getelementptr inbounds [65 x i8], [65 x i8]* %6, i64 0, i64 0
%8 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [65 x i8], [65 x i8]* %6, i64 0, i64 16
%10 = load i32, i32* %3
%11 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 15)
%12 = getelementptr inbounds [65 x i8], [65 x i8]* %6, i64 0, i64 31
store i8 59, i8* %12
%13 = getelementptr inbounds [65 x i8], [65 x i8]* %6, i64 0, i64 32
%14 = call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32, i32* %4
switch i32 %15, label %22 [
i32 0, label %16
i32 1, label %19
]
16: ; preds = %2
%17 = getelementptr inbounds [65 x i8], [65 x i8]* %6, i64 0, i64 46
%18 = call i32 @strcpy(i8* %17, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %23
19: ; preds = %2
%20 = getelementptr inbounds [65 x i8], [65 x i8]* %6, i64 0, i64 46
%21 = call i32 @strcpy(i8* %20, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
br label %23
22: ; preds = %2
store i32 -22, i32* %5
br label %23
23: ; preds = %22, %19, %16
%24 = getelementptr inbounds [65 x i8], [65 x i8]* %6, i64 0, i64 62
store i8 59, i8* %24
%25 = getelementptr inbounds [65 x i8], [65 x i8]* %6, i64 0, i64 63
store i8 10, i8* %25
%26 = getelementptr inbounds [65 x i8], [65 x i8]* %6, i64 0, i64 64
store i8 0, i8* %26
%27 = load i32, i32* %5
%28 = icmp eq i32 %27, -10
br i1 %28, label %29, label %32
29: ; preds = %23
%30 = getelementptr inbounds [65 x i8], [65 x i8]* %6, i64 0, i64 0
%31 = call i32 @sendString(i8* %30)
store i32 %31, i32* %5
br label %32
32: ; preds = %29, %23
%33 = load i32, i32* %5
ret i32 %33
}

LLVM IR (-O2):
@.str = [17 x i8] c"Content-length: \00"
@.str.1 = [4 x i8] c"%*d\00"
@.str.2 = [15 x i8] c"Content-type: \00"
@.str.3 = [10 x i8] c"ObjectBid\00"
@.str.4 = [12 x i8] c"UserAccount\00"
define i32 @sendHeaderField(i32 %0, i32 %1) {
%3 = alloca [65 x i8]
%4 = getelementptr inbounds [65 x i8], [65 x i8]* %3, i64 0, i64 0
%5 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [65 x i8], [65 x i8]* %3, i64 0, i64 16
%7 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %0, i32 15)
%8 = getelementptr inbounds [65 x i8], [65 x i8]* %3, i64 0, i64 31
store i8 59, i8* %8
%9 = getelementptr inbounds [65 x i8], [65 x i8]* %3, i64 0, i64 32
%10 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
switch i32 %1, label %20 [
i32 0, label %12
i32 1, label %11
]
11: ; preds = %2
br label %12
12: ; preds = %2, %11
%13 = phi i8* [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), %11 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), %2 ]
%14 = getelementptr inbounds [65 x i8], [65 x i8]* %3, i64 0, i64 46
%15 = call i32 @strcpy(i8* %14, i8* %13)
%16 = getelementptr inbounds [65 x i8], [65 x i8]* %3, i64 0, i64 62
store i8 59, i8* %16
%17 = getelementptr inbounds [65 x i8], [65 x i8]* %3, i64 0, i64 63
store i8 10, i8* %17
%18 = getelementptr inbounds [65 x i8], [65 x i8]* %3, i64 0, i64 64
store i8 0, i8* %18
%19 = call i32 @sendString(i8* %4)
br label %20
20: ; preds = %2, %12
%21 = phi i32 [ %19, %12 ], [ -22, %2 ]
ret i32 %21
}