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

/* Variables and functions */
int /*<<< orphan*/ do_local_client_step(int, void (*)(char *));
int local_client_create(struct local_conf *);
int /*<<< orphan*/ local_client_destroy(int);
int send(int, int *, int, int /*<<< orphan*/);
int do_local_request(int request, struct local_conf *conf,
                     void (*step)(char *buf)) {
  int fd, ret;
  fd = local_client_create(conf);
  if (fd == -1)
    return -1;
  ret = send(fd, &request, sizeof(int), 0);
  if (ret == -1)
    return -1;
  do_local_client_step(fd, step);
  local_client_destroy(fd);
  return 0;
}


x86 assembly (clang, -O0):
<do_local_request>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <local_client_create@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1175 <do_local_request+0x35>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bc <do_local_request+0x7c>
mov    -0x1c(%rbp),%edi
lea    -0x8(%rbp),%rsi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
jne    11a1 <do_local_request+0x61>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bc <do_local_request+0x7c>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1060 <do_local_client_step@plt>
mov    -0x1c(%rbp),%edi
call   1050 <local_client_destroy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_local_request>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %edi,0xc(%rsp)
mov    %rsi,%rdi
call   1030 <local_client_create@plt>
mov    $0xffffffff,%ebx
cmp    $0xffffffff,%eax
je     118e <do_local_request+0x4e>
mov    %eax,%ebp
lea    0xc(%rsp),%rsi
mov    %eax,%edi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
cmp    $0xffffffff,%eax
je     118e <do_local_request+0x4e>
mov    %ebp,%edi
mov    %r14,%rsi
call   1060 <do_local_client_step@plt>
mov    %ebp,%edi
call   1050 <local_client_destroy@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.local_conf = type { i32 }
define i32 @do_local_request(i32 %0, %struct.local_conf* %1, void (i8*)* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.local_conf*
%7 = alloca void (i8*)*
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %5
store %struct.local_conf* %1, %struct.local_conf** %6
store void (i8*)* %2, void (i8*)** %7
%10 = load %struct.local_conf*, %struct.local_conf** %6
%11 = call i32 @local_client_create(%struct.local_conf* %10)
store i32 %11, i32* %8
%12 = load i32, i32* %8
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %15
14: ; preds = %3
store i32 -1, i32* %4
br label %27
15: ; preds = %3
%16 = load i32, i32* %8
%17 = call i32 @send(i32 %16, i32* %5, i32 4, i32 0)
store i32 %17, i32* %9
%18 = load i32, i32* %9
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %21
20: ; preds = %15
store i32 -1, i32* %4
br label %27
21: ; preds = %15
%22 = load i32, i32* %8
%23 = load void (i8*)*, void (i8*)** %7
%24 = call i32 @do_local_client_step(i32 %22, void (i8*)* %23)
%25 = load i32, i32* %8
%26 = call i32 @local_client_destroy(i32 %25)
store i32 0, i32* %4
br label %27
27: ; preds = %21, %20, %14
%28 = load i32, i32* %4
ret i32 %28
}

LLVM IR (-O2):
%struct.local_conf = type { i32 }
define i32 @do_local_request(i32 %0, %struct.local_conf* %1, void (i8*)* %2) {
%4 = alloca i32
store i32 %0, i32* %4
%5 = tail call i32 @local_client_create(%struct.local_conf* %1)
%6 = icmp eq i32 %5, -1
br i1 %6, label %13, label %7
7: ; preds = %3
%8 = call i32 @send(i32 %5, i32* %4, i32 4, i32 0)
%9 = icmp eq i32 %8, -1
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = call i32 @do_local_client_step(i32 %5, void (i8*)* %2)
%12 = call i32 @local_client_destroy(i32 %5)
br label %13
13: ; preds = %7, %3, %10
%14 = phi i32 [ 0, %10 ], [ -1, %3 ], [ -1, %7 ]
ret i32 %14
}