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

/* Variables and functions */
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ close(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
scalar_t__ write(int, char *, int /*<<< orphan*/);
void set_oom_score_adj(void) {
  int fd;
  char val[] = "-1000";
  fd = open("/proc/self/oom_score_adj", O_RDWR);
  if (fd < 0) {
    return;
  }
  if (write(fd, val, strlen(val)) < 0)
    ;
  close(fd);
}


x86 assembly (clang, -O0):
<set_oom_score_adj>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xeb2(%rip),%eax
mov    %eax,-0xa(%rbp)
mov    0xeac(%rip),%ax
mov    %ax,-0x6(%rbp)
mov    0x2e85(%rip),%rax
mov    (%rax),%esi
lea    0xe9a(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1183 <set_oom_score_adj+0x43>
jmp    11bf <set_oom_score_adj+0x7f>
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
lea    -0xa(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0xa(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
cmp    $0x0,%rax
jge    11b7 <set_oom_score_adj+0x77>
jmp    11b7 <set_oom_score_adj+0x77>
mov    -0x4(%rbp),%edi
call   1050 <close@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_oom_score_adj>:
push   %r14
push   %rbx
push   %rax
movw   $0x30,0x4(%rsp)
movl   $0x3030312d,(%rsp)
mov    0x2e8f(%rip),%rax
mov    (%rax),%esi
lea    0xea4(%rip),%rdi
call   1060 <open@plt>
test   %eax,%eax
js     118b <set_oom_score_adj+0x4b>
mov    %eax,%ebx
mov    %rsp,%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %ebx,%edi
call   1050 <close@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.set_oom_score_adj.val = [6 x i8] c"-1000\00"
@.str = [25 x i8] c"/proc/self/oom_score_adj\00"
@O_RDWR = global i32 0
define void @set_oom_score_adj() {
%1 = alloca i32
%2 = alloca [6 x i8]
%3 = bitcast [6 x i8]* %2 to i8*
%4 = load i32, i32* @O_RDWR
%5 = call i32 @open(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %4)
store i32 %5, i32* %1
%6 = load i32, i32* %1
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %0
br label %20
9: ; preds = %0
%10 = load i32, i32* %1
%11 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%12 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%13 = call i32 @strlen(i8* %12)
%14 = call i64 @write(i32 %10, i8* %11, i32 %13)
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %9
br label %17
17: ; preds = %16, %9
%18 = load i32, i32* %1
%19 = call i32 @close(i32 %18)
br label %20
20: ; preds = %17, %8
ret void
}

LLVM IR (-O2):
@__const.set_oom_score_adj.val = [6 x i8] c"-1000\00"
@.str = [25 x i8] c"/proc/self/oom_score_adj\00"
@O_RDWR = global i32 0
define void @set_oom_score_adj() {
%1 = alloca [6 x i8]
%2 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @O_RDWR
%4 = tail call i32 @open(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = icmp slt i32 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %0
%7 = call i32 @strlen(i8* %2)
%8 = call i64 @write(i32 %4, i8* %2, i32 %7)
%9 = call i32 @close(i32 %4)
br label %10
10: ; preds = %0, %6
ret void
}