#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 proxy_worker {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ perror(char *);
scalar_t__ proxy_worker_send(struct proxy_worker *, char const *, int);
int snprintf(char *, int, char *, char const *, char const *);
int proxy_worker_request(struct proxy_worker *worker, const char *method,
                         const char *uri) {
  char buf[256];
  int len = snprintf(buf, sizeof buf, "%s /%s HTTP/1.1\r\n", method, uri);
  if (len < 0) {
    perror("snprintf: worker http request");
    return 1;
  }
  if (proxy_worker_send(worker, (const char *)buf, len))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<proxy_worker_request>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    $0x100,%esi
lea    0xe9e(%rip),%rdx
call   1030 <snprintf@plt>
mov    %eax,-0x124(%rbp)
cmpl   $0x0,-0x124(%rbp)
jge    1192 <proxy_worker_request+0x62>
lea    0xe91(%rip),%rdi
call   1040 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    11c5 <proxy_worker_request+0x95>
mov    -0x10(%rbp),%rdi
lea    -0x120(%rbp),%rsi
mov    -0x124(%rbp),%edx
call   1050 <proxy_worker_send@plt>
cmp    $0x0,%rax
je     11be <proxy_worker_request+0x8e>
movl   $0x1,-0x4(%rbp)
jmp    11c5 <proxy_worker_request+0x95>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<proxy_worker_request>:
push   %rbx
sub    $0x100,%rsp
mov    %rdx,%r8
mov    %rsi,%rcx
mov    %rdi,%rbx
lea    0xeb8(%rip),%rdx
mov    %rsp,%rdi
mov    $0x100,%esi
call   1030 <snprintf@plt>
test   %eax,%eax
js     117a <proxy_worker_request+0x4a>
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    %eax,%edx
call   1050 <proxy_worker_send@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
add    $0x100,%rsp
pop    %rbx
ret
lea    0xe91(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%eax
jmp    1171 <proxy_worker_request+0x41>

LLVM IR (-O0):
%struct.proxy_worker = type { i32 }
@.str = [18 x i8] c"%s /%s HTTP/1.1\0D\0A\00"
@.str.1 = [30 x i8] c"snprintf: worker http request\00"
define i32 @proxy_worker_request(%struct.proxy_worker* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca %struct.proxy_worker*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [256 x i8]
%9 = alloca i32
store %struct.proxy_worker* %0, %struct.proxy_worker** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%11 = load i8*, i8** %6
%12 = load i8*, i8** %7
%13 = call i32 @snprintf(i8* %10, i32 256, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %11, i8* %12)
store i32 %13, i32* %9
%14 = load i32, i32* %9
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %3
%17 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %4
br label %26
18: ; preds = %3
%19 = load %struct.proxy_worker*, %struct.proxy_worker** %5
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%21 = load i32, i32* %9
%22 = call i64 @proxy_worker_send(%struct.proxy_worker* %19, i8* %20, i32 %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %18
store i32 1, i32* %4
br label %26
25: ; preds = %18
store i32 0, i32* %4
br label %26
26: ; preds = %25, %24, %16
%27 = load i32, i32* %4
ret i32 %27
}

LLVM IR (-O2):
%struct.proxy_worker = type { i32 }
@.str = [18 x i8] c"%s /%s HTTP/1.1\0D\0A\00"
@.str.1 = [30 x i8] c"snprintf: worker http request\00"
define i32 @proxy_worker_request(%struct.proxy_worker* %0, i8* %1, i8* %2) {
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%6 = call i32 @snprintf(i8* %5, i32 256, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2)
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
br label %14
10: ; preds = %3
%11 = call i64 @proxy_worker_send(%struct.proxy_worker* %0, i8* %5, i32 %6)
%12 = icmp ne i64 %11, 0
%13 = zext i1 %12 to i32
br label %14
14: ; preds = %10, %8
%15 = phi i32 [ 1, %8 ], [ %13, %10 ]
ret i32 %15
}