#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 epoll_event {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int my_epoll_wait(int, struct epoll_event *, int, int);
int my_epoll_wait_arm(int epfd, struct epoll_event *events, int maxevents,
                      int timeout) {
  {
    FILE *fp = fopen("/data/local/tmp/arm_arthook.log", "a+");
    if (fp) {
      fprintf(fp, "cippa dentro epoll arm \n");
      fclose(fp);
    }
  };
  return my_epoll_wait(epfd, events, maxevents, timeout);
}


x86 assembly (clang, -O0):
<my_epoll_wait_arm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
lea    0xea4(%rip),%rdi
lea    0xebd(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1190 <my_epoll_wait_arm+0x50>
mov    -0x20(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1040 <my_epoll_wait@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_epoll_wait_arm>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %rsi,%r12
mov    %edi,%ebp
lea    0xea6(%rip),%rdi
lea    0xebf(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     118f <my_epoll_wait_arm+0x4f>
mov    %rax,%rbx
lea    0xeae(%rip),%rdi
mov    $0x18,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1060 <fwrite@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %ebp,%edi
mov    %r12,%rsi
mov    %r15d,%edx
mov    %r14d,%ecx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <my_epoll_wait@plt>

LLVM IR (-O0):
%struct.epoll_event = type { i32 }
@.str = [32 x i8] c"/data/local/tmp/arm_arthook.log\00"
@.str.1 = [3 x i8] c"a+\00"
@.str.2 = [25 x i8] c"cippa dentro epoll arm \0A\00"
define i32 @my_epoll_wait_arm(i32 %0, %struct.epoll_event* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca %struct.epoll_event*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
store i32 %0, i32* %5
store %struct.epoll_event* %1, %struct.epoll_event** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = call i32* @fopen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %9
%11 = load i32*, i32** %9
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %18
13: ; preds = %4
%14 = load i32*, i32** %9
%15 = call i32 @fprintf(i32* %14, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32*, i32** %9
%17 = call i32 @fclose(i32* %16)
br label %18
18: ; preds = %13, %4
%19 = load i32, i32* %5
%20 = load %struct.epoll_event*, %struct.epoll_event** %6
%21 = load i32, i32* %7
%22 = load i32, i32* %8
%23 = call i32 @my_epoll_wait(i32 %19, %struct.epoll_event* %20, i32 %21, i32 %22)
ret i32 %23
}

LLVM IR (-O2):
%struct.epoll_event = type { i32 }
@.str = [32 x i8] c"/data/local/tmp/arm_arthook.log\00"
@.str.1 = [3 x i8] c"a+\00"
@.str.2 = [25 x i8] c"cippa dentro epoll arm \0A\00"
define i32 @my_epoll_wait_arm(i32 %0, %struct.epoll_event* %1, i32 %2, i32 %3) {
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i64 24, i64 1, i32* %5)
%9 = tail call i32 @fclose(i32* %5)
br label %10
10: ; preds = %7, %4
%11 = tail call i32 @my_epoll_wait(i32 %0, %struct.epoll_event* %1, i32 %2, i32 %3)
ret i32 %11
}