#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 iiod_client {
  int dummy;
};
struct iio_device {
  int dummy;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
char *iio_device_get_id(struct iio_device const *);
int iiod_client_exec_command(struct iiod_client *, int, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int iiod_client_close_unlocked(struct iiod_client *client, int desc,
                               const struct iio_device *dev) {
  char buf[1024];
  snprintf(buf, sizeof(buf), "CLOSE %s\r\n", iio_device_get_id(dev));
  return iiod_client_exec_command(client, desc, buf);
}


x86 assembly (clang, -O0):
<iiod_client_close_unlocked>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x420(%rbp),%rax
mov    %rax,-0x428(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <iio_device_get_id@plt>
mov    -0x428(%rbp),%rdi
mov    %rax,%rcx
mov    $0x400,%esi
lea    0xe8d(%rip),%rdx
call   1030 <snprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    -0x420(%rbp),%rdx
call   1040 <iiod_client_exec_command@plt>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iiod_client_close_unlocked>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
mov    %rdx,%rdi
call   1050 <iio_device_get_id@plt>
lea    0xeb1(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x400,%esi
mov    %rax,%rcx
call   1030 <snprintf@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14,%rdx
call   1040 <iiod_client_exec_command@plt>
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.iiod_client = type { i32 }
%struct.iio_device = type { i32 }
@.str = [11 x i8] c"CLOSE %s\0D\0A\00"
define i32 @iiod_client_close_unlocked(%struct.iiod_client* %0, i32 %1, %struct.iio_device* %2) {
%4 = alloca %struct.iiod_client*
%5 = alloca i32
%6 = alloca %struct.iio_device*
%7 = alloca [1024 x i8]
store %struct.iiod_client* %0, %struct.iiod_client** %4
store i32 %1, i32* %5
store %struct.iio_device* %2, %struct.iio_device** %6
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%9 = load %struct.iio_device*, %struct.iio_device** %6
%10 = call i8* @iio_device_get_id(%struct.iio_device* %9)
%11 = call i32 @snprintf(i8* %8, i32 1024, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load %struct.iiod_client*, %struct.iiod_client** %4
%13 = load i32, i32* %5
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%15 = call i32 @iiod_client_exec_command(%struct.iiod_client* %12, i32 %13, i8* %14)
ret i32 %15
}

LLVM IR (-O2):
%struct.iiod_client = type { i32 }
%struct.iio_device = type { i32 }
@.str = [11 x i8] c"CLOSE %s\0D\0A\00"
define i32 @iiod_client_close_unlocked(%struct.iiod_client* %0, i32 %1, %struct.iio_device* %2) {
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%6 = tail call i8* @iio_device_get_id(%struct.iio_device* %2)
%7 = call i32 @snprintf(i8* %5, i32 1024, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = call i32 @iiod_client_exec_command(%struct.iiod_client* %0, i32 %1, i8* %5)
ret i32 %8
}