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

/* Variables and functions */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int write_file(char *, char *, int);
int set_sync_status(void *capture, int index) {
  char sync[5];
  char file_path[20];
  memset(sync, 0, sizeof(sync));
  sprintf(sync, "%d", index);
  strcpy(file_path, "dev/sync");
  return write_file(file_path, sync, sizeof(sync));
}


x86 assembly (clang, -O0):
<set_sync_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x11(%rbp),%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1050 <memset@plt>
lea    -0x11(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe93(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x30(%rbp),%rdi
lea    0xe86(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x30(%rbp),%rdi
lea    -0x11(%rbp),%rsi
mov    $0x5,%edx
call   1040 <write_file@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_sync_status>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %esi,%ebx
lea    0xb(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1050 <memset@plt>
lea    0xe9c(%rip),%rsi
mov    %r14,%rdi
mov    %ebx,%edx
call   1060 <sprintf@plt>
lea    0xe8e(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x5,%edx
call   1040 <write_file@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [9 x i8] c"dev/sync\00"
define i32 @set_sync_status(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [5 x i8]
%6 = alloca [20 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%8 = call i32 @memset(i8* %7, i32 0, i32 5)
%9 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%10 = load i32, i32* %4
%11 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%13 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%15 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%16 = call i32 @write_file(i8* %14, i8* %15, i32 5)
ret i32 %16
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [9 x i8] c"dev/sync\00"
define i32 @set_sync_status(i8* nocapture readnone %0, i32 %1) {
%3 = alloca [5 x i8]
%4 = alloca [20 x i8]
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%7 = call i32 @memset(i8* %5, i32 0, i32 5)
%8 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %1)
%9 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @write_file(i8* %6, i8* %5, i32 5)
ret i32 %10
}