#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 utimbuf {
  int /*<<< orphan*/ member_1;
  int /*<<< orphan*/ member_0;
};
struct stat {
  int /*<<< orphan*/ st_mode;
  int /*<<< orphan*/ st_gid;
  int /*<<< orphan*/ st_uid;
  int /*<<< orphan*/ st_mtime;
  int /*<<< orphan*/ st_atime;
};

/* Variables and functions */
int /*<<< orphan*/ chmod(char *, int /*<<< orphan*/);
int /*<<< orphan*/ chown(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ utime(char *, struct utimbuf *);
void set_attributes(char *filename, struct stat *bufp) {
  struct utimbuf ut = {bufp->st_atime, bufp->st_mtime};
  utime(filename, &ut);
  chown(filename, bufp->st_uid, bufp->st_gid);
  chmod(filename, bufp->st_mode);
}


x86 assembly (clang, -O0):
<set_attributes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <utime@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%esi
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edx
call   1040 <chown@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
call   1050 <chmod@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_attributes>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    0x10(%rsi),%eax
mov    %eax,(%rsp)
mov    0xc(%rsi),%eax
mov    %eax,0x4(%rsp)
mov    %rsp,%rsi
call   1030 <utime@plt>
mov    0x4(%rbx),%edx
mov    0x8(%rbx),%esi
mov    %r14,%rdi
call   1040 <chown@plt>
mov    (%rbx),%esi
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <chmod@plt>

LLVM IR (-O0):
%struct.stat = type { i32, i32, i32, i32, i32 }
%struct.utimbuf = type { i32, i32 }
define void @set_attributes(i8* %0, %struct.stat* %1) {
%3 = alloca i8*
%4 = alloca %struct.stat*
%5 = alloca %struct.utimbuf
store i8* %0, i8** %3
store %struct.stat* %1, %struct.stat** %4
%6 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %5, i32 0, i32 0
%7 = load %struct.stat*, %struct.stat** %4
%8 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 4
%9 = load i32, i32* %8
store i32 %9, i32* %6
%10 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %5, i32 0, i32 1
%11 = load %struct.stat*, %struct.stat** %4
%12 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 3
%13 = load i32, i32* %12
store i32 %13, i32* %10
%14 = load i8*, i8** %3
%15 = call i32 @utime(i8* %14, %struct.utimbuf* %5)
%16 = load i8*, i8** %3
%17 = load %struct.stat*, %struct.stat** %4
%18 = getelementptr inbounds %struct.stat, %struct.stat* %17, i32 0, i32 2
%19 = load i32, i32* %18
%20 = load %struct.stat*, %struct.stat** %4
%21 = getelementptr inbounds %struct.stat, %struct.stat* %20, i32 0, i32 1
%22 = load i32, i32* %21
%23 = call i32 @chown(i8* %16, i32 %19, i32 %22)
%24 = load i8*, i8** %3
%25 = load %struct.stat*, %struct.stat** %4
%26 = getelementptr inbounds %struct.stat, %struct.stat* %25, i32 0, i32 0
%27 = load i32, i32* %26
%28 = call i32 @chmod(i8* %24, i32 %27)
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32, i32, i32, i32, i32 }
%struct.utimbuf = type { i32, i32 }
define void @set_attributes(i8* nocapture %0, %struct.stat* nocapture %1) {
%3 = alloca %struct.utimbuf
%4 = bitcast %struct.utimbuf* %3 to i8*
%5 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %3, i64 0, i32 0
%6 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 4
%7 = load i32, i32* %6
store i32 %7, i32* %5
%8 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %3, i64 0, i32 1
%9 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 3
%10 = load i32, i32* %9
store i32 %10, i32* %8
%11 = call i32 @utime(i8* %0, %struct.utimbuf* %3)
%12 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 2
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 1
%15 = load i32, i32* %14
%16 = tail call i32 @chown(i8* %0, i32 %13, i32 %15)
%17 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 0
%18 = load i32, i32* %17
%19 = tail call i32 @chmod(i8* %0, i32 %18)
ret void
}