#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 atoi(char *);
int /*<<< orphan*/ free(char *);
scalar_t__ omb_utils_file_exists(char *);
char *omb_utils_read(char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ system(char *);
void omb_utils_setrctype() {
  char tmp[255];
  sprintf(tmp, "%s/%s/.%s", "/omb", "open-multiboot", "rctype");
  if (omb_utils_file_exists(tmp)) {
    char *tmp = omb_utils_read("rctype");
    if (tmp) {
      int ret = atoi(tmp);
      free(tmp);
      if (ret) {
        char cmd[255];
        sprintf(cmd, "echo %d > /proc/stb/ir/rc/type", ret);
        system(cmd);
      }
    }
  }
}


x86 assembly (clang, -O0):
<omb_utils_setrctype>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
lea    -0x100(%rbp),%rdi
lea    0xe87(%rip),%rsi
lea    0xe8a(%rip),%rdx
lea    0xe88(%rip),%rcx
lea    0xe90(%rip),%r8
mov    $0x0,%al
call   1080 <sprintf@plt>
lea    -0x100(%rbp),%rdi
call   1030 <omb_utils_file_exists@plt>
cmp    $0x0,%rax
je     1228 <omb_utils_setrctype+0xc8>
lea    0xe6c(%rip),%rdi
call   1060 <omb_utils_read@plt>
mov    %rax,-0x108(%rbp)
cmpq   $0x0,-0x108(%rbp)
je     1223 <omb_utils_setrctype+0xc3>
mov    -0x108(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x10c(%rbp)
mov    -0x108(%rbp),%rdi
call   1040 <free@plt>
cmpl   $0x0,-0x10c(%rbp)
je     121e <omb_utils_setrctype+0xbe>
lea    -0x210(%rbp),%rdi
mov    -0x10c(%rbp),%edx
lea    0xe1a(%rip),%rsi
mov    $0x0,%al
call   1080 <sprintf@plt>
lea    -0x210(%rbp),%rdi
call   1050 <system@plt>
jmp    1223 <omb_utils_setrctype+0xc3>
jmp    1228 <omb_utils_setrctype+0xc8>
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<omb_utils_setrctype>:
push   %rbp
push   %rbx
sub    $0x208,%rsp
lea    0xe90(%rip),%rsi
lea    0xe93(%rip),%rdx
lea    0xe91(%rip),%rcx
lea    0xe99(%rip),%r8
lea    0x100(%rsp),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <omb_utils_file_exists@plt>
test   %rax,%rax
je     11ec <omb_utils_setrctype+0x8c>
lea    0xe73(%rip),%rdi
call   1060 <omb_utils_read@plt>
test   %rax,%rax
je     11ec <omb_utils_setrctype+0x8c>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <atoi@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <free@plt>
test   %ebp,%ebp
je     11ec <omb_utils_setrctype+0x8c>
lea    0xe50(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <system@plt>
add    $0x208,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%s/%s/.%s\00"
@.str.1 = [5 x i8] c"/omb\00"
@.str.2 = [15 x i8] c"open-multiboot\00"
@.str.3 = [7 x i8] c"rctype\00"
@.str.4 = [31 x i8] c"echo %d > /proc/stb/ir/rc/type\00"
define void @omb_utils_setrctype() {
%1 = alloca [255 x i8]
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [255 x i8]
%5 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 0
%6 = call i32 (i8*, i8*, ...) @sprintf(i8* %5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%7 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 0
%8 = call i64 @omb_utils_file_exists(i8* %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %29
10: ; preds = %0
%11 = call i8* @omb_utils_read(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
store i8* %11, i8** %2
%12 = load i8*, i8** %2
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %28
14: ; preds = %10
%15 = load i8*, i8** %2
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %3
%17 = load i8*, i8** %2
%18 = call i32 @free(i8* %17)
%19 = load i32, i32* %3
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %27
21: ; preds = %14
%22 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%23 = load i32, i32* %3
%24 = call i32 (i8*, i8*, ...) @sprintf(i8* %22, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%26 = call i32 @system(i8* %25)
br label %27
27: ; preds = %21, %14
br label %28
28: ; preds = %27, %10
br label %29
29: ; preds = %28, %0
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"%s/%s/.%s\00"
@.str.1 = [5 x i8] c"/omb\00"
@.str.2 = [15 x i8] c"open-multiboot\00"
@.str.3 = [7 x i8] c"rctype\00"
@.str.4 = [31 x i8] c"echo %d > /proc/stb/ir/rc/type\00"
define void @omb_utils_setrctype() {
%1 = alloca [255 x i8]
%2 = alloca [255 x i8]
%3 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 0
%4 = call i32 (i8*, i8*, ...) @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%5 = call i64 @omb_utils_file_exists(i8* %3)
%6 = icmp eq i64 %5, 0
br i1 %6, label %18, label %7
7: ; preds = %0
%8 = call i8* @omb_utils_read(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%9 = icmp eq i8* %8, null
br i1 %9, label %18, label %10
10: ; preds = %7
%11 = call i32 @atoi(i8* %8)
%12 = call i32 @free(i8* %8)
%13 = icmp eq i32 %11, 0
br i1 %13, label %18, label %14
14: ; preds = %10
%15 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%16 = call i32 (i8*, i8*, ...) @sprintf(i8* %15, i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %11)
%17 = call i32 @system(i8* %15)
br label %18
18: ; preds = %7, %14, %10, %0
ret void
}