#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*/ obuf;

/* Variables and functions */
int /*<<< orphan*/ send_packet(char *);
int /*<<< orphan*/ send_packet_no_ack(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char, int);
void send_response(char code, int sigval, bool wait_for_ack) {
  char obuf[4096];
  snprintf(obuf, sizeof(obuf), "%c%02x", code, sigval);
  if (wait_for_ack)
    send_packet(obuf);
  else
    send_packet_no_ack(obuf);
}


x86 assembly (clang, -O0):
<send_response>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1010,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
lea    -0x1010(%rbp),%rdi
mov    -0x1(%rbp),%al
mov    -0x8(%rbp),%r8d
mov    $0x1000,%esi
lea    0xe9f(%rip),%rdx
movsbl %al,%ecx
call   1030 <snprintf@plt>
cmpl   $0x0,-0xc(%rbp)
je     1184 <send_response+0x54>
lea    -0x1010(%rbp),%rdi
call   1050 <send_packet@plt>
jmp    1190 <send_response+0x60>
lea    -0x1010(%rbp),%rdi
call   1040 <send_packet_no_ack@plt>
add    $0x1010,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_response>:
push   %rbx
sub    $0x1000,%rsp
mov    %edx,%ebx
mov    %esi,%r8d
mov    %edi,%ecx
lea    0xeba(%rip),%rdx
mov    %rsp,%rdi
mov    $0x1000,%esi
call   1030 <snprintf@plt>
mov    %rsp,%rdi
test   %ebx,%ebx
je     1161 <send_response+0x31>
call   1050 <send_packet@plt>
jmp    1166 <send_response+0x36>
call   1040 <send_packet_no_ack@plt>
add    $0x1000,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%c%02x\00"
define void @send_response(i8 signext %0, i32 %1, i32 %2) {
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
%7 = alloca [4096 x i8]
store i8 %0, i8* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%9 = load i8, i8* %4
%10 = load i32, i32* %5
%11 = call i32 @snprintf(i8* %8, i32 4096, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext %9, i32 %10)
%12 = load i32, i32* %6
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %3
%15 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%16 = call i32 @send_packet(i8* %15)
br label %20
17: ; preds = %3
%18 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%19 = call i32 @send_packet_no_ack(i8* %18)
br label %20
20: ; preds = %17, %14
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%c%02x\00"
define void @send_response(i8 signext %0, i32 %1, i32 %2) {
%4 = alloca [4096 x i8]
%5 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%6 = call i32 @snprintf(i8* %5, i32 4096, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext %0, i32 %1)
%7 = icmp eq i32 %2, 0
br i1 %7, label %10, label %8
8: ; preds = %3
%9 = call i32 @send_packet(i8* %5)
br label %12
10: ; preds = %3
%11 = call i32 @send_packet_no_ack(i8* %5)
br label %12
12: ; preds = %10, %8
ret void
}