#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*/ fprintf(int /*<<< orphan*/, char *, ...);
long get_sensor_update_interval(char *);
int /*<<< orphan*/ stderr;
long get_update_interval() {
  long ret = 0;
  long tmp;
  tmp = get_sensor_update_interval("4-0040");
  if (tmp < 0) {
    fprintf(stderr, "get_update_interval: Warning: could not read A15 update "
                    "interval\n");
  }
  ret = tmp > ret ? tmp : ret;
  tmp = get_sensor_update_interval("4-0045");
  if (tmp < 0) {
    fprintf(stderr, "get_update_interval: Warning: could not read A7 update "
                    "interval\n");
  }
  ret = tmp > ret ? tmp : ret;
  tmp = get_sensor_update_interval("4-0041");
  if (tmp < 0) {
    fprintf(stderr, "get_update_interval: Warning: could not read MEM update "
                    "interval\n");
  }
  ret = tmp > ret ? tmp : ret;
  tmp = get_sensor_update_interval("4-0044");
  if (tmp < 0) {
    fprintf(stderr, "get_update_interval: Warning: could not read GPU update "
                    "interval\n");
  }
  ret = tmp > ret ? tmp : ret;
  if (ret == 0) {
    ret = 263808;
    fprintf(stderr, "get_update_interval: Using default value: %ld us\n", ret);
  }
  return ret;
}


x86 assembly (clang, -O0):
<get_update_interval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movq   $0x0,-0x8(%rbp)
lea    0xec9(%rip),%rdi
call   1030 <get_sensor_update_interval@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jge    1162 <get_update_interval+0x42>
mov    0x2e8e(%rip),%rax
mov    (%rax),%edi
lea    0xeac(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
jle    117d <get_update_interval+0x5d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    1185 <get_update_interval+0x65>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
lea    0xeb5(%rip),%rdi
call   1030 <get_sensor_update_interval@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jge    11bf <get_update_interval+0x9f>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
jle    11da <get_update_interval+0xba>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    11e2 <get_update_interval+0xc2>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
lea    0xea0(%rip),%rdi
call   1030 <get_sensor_update_interval@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jge    121c <get_update_interval+0xfc>
mov    0x2dd4(%rip),%rax
mov    (%rax),%edi
lea    0xe83(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
jle    1237 <get_update_interval+0x117>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    123f <get_update_interval+0x11f>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
lea    0xe8c(%rip),%rdi
call   1030 <get_sensor_update_interval@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jge    1279 <get_update_interval+0x159>
mov    0x2d77(%rip),%rax
mov    (%rax),%edi
lea    0xe6f(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
jle    1294 <get_update_interval+0x174>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    129c <get_update_interval+0x17c>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    12d2 <get_update_interval+0x1b2>
movq   $0x40680,-0x8(%rbp)
mov    0x2d22(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe58(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_update_interval>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%rdi
call   1030 <get_sensor_update_interval@plt>
mov    %rax,%r14
test   %rax,%rax
jns    114f <get_update_interval+0x2f>
mov    0x2ea1(%rip),%rax
mov    (%rax),%edi
lea    0xebf(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %ebx,%ebx
test   %r14,%r14
cmovns %r14,%rbx
lea    0xeea(%rip),%rdi
call   1030 <get_sensor_update_interval@plt>
mov    %rax,%r14
test   %rax,%rax
jns    1183 <get_update_interval+0x63>
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
lea    0xed4(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
cmp    %rbx,%r14
cmovg  %r14,%rbx
lea    0xf00(%rip),%rdi
call   1030 <get_sensor_update_interval@plt>
mov    %rax,%r14
test   %rax,%rax
jns    11b5 <get_update_interval+0x95>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
lea    0xeea(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
cmp    %rbx,%r14
cmovg  %r14,%rbx
lea    0xf17(%rip),%rdi
call   1030 <get_sensor_update_interval@plt>
mov    %rax,%r14
test   %rax,%rax
jns    11e7 <get_update_interval+0xc7>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
lea    0xf01(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
cmp    %rbx,%r14
cmovg  %r14,%rbx
test   %rbx,%rbx
jne    1214 <get_update_interval+0xf4>
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
lea    0xf20(%rip),%rsi
mov    $0x40680,%ebx
mov    $0x40680,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"4-0040\00"
@stderr = global i32 0
@.str.1 = [66 x i8] c"get_update_interval: Warning: could not read A15 update interval\0A\00"
@.str.2 = [7 x i8] c"4-0045\00"
@.str.3 = [65 x i8] c"get_update_interval: Warning: could not read A7 update interval\0A\00"
@.str.4 = [7 x i8] c"4-0041\00"
@.str.5 = [66 x i8] c"get_update_interval: Warning: could not read MEM update interval\0A\00"
@.str.6 = [7 x i8] c"4-0044\00"
@.str.7 = [66 x i8] c"get_update_interval: Warning: could not read GPU update interval\0A\00"
@.str.8 = [50 x i8] c"get_update_interval: Using default value: %ld us\0A\00"
define i64 @get_update_interval() {
%1 = alloca i64
%2 = alloca i64
store i64 0, i64* %1
%3 = call i64 @get_sensor_update_interval(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i64 %3, i64* %2
%4 = load i64, i64* %2
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.1, i64 0, i64 0))
br label %9
9: ; preds = %6, %0
%10 = load i64, i64* %2
%11 = load i64, i64* %1
%12 = icmp sgt i64 %10, %11
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = load i64, i64* %2
br label %17
15: ; preds = %9
%16 = load i64, i64* %1
br label %17
17: ; preds = %15, %13
%18 = phi i64 [ %14, %13 ], [ %16, %15 ]
store i64 %18, i64* %1
%19 = call i64 @get_sensor_update_interval(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
store i64 %19, i64* %2
%20 = load i64, i64* %2
%21 = icmp slt i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = load i32, i32* @stderr
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.3, i64 0, i64 0))
br label %25
25: ; preds = %22, %17
%26 = load i64, i64* %2
%27 = load i64, i64* %1
%28 = icmp sgt i64 %26, %27
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = load i64, i64* %2
br label %33
31: ; preds = %25
%32 = load i64, i64* %1
br label %33
33: ; preds = %31, %29
%34 = phi i64 [ %30, %29 ], [ %32, %31 ]
store i64 %34, i64* %1
%35 = call i64 @get_sensor_update_interval(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
store i64 %35, i64* %2
%36 = load i64, i64* %2
%37 = icmp slt i64 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %33
%39 = load i32, i32* @stderr
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.5, i64 0, i64 0))
br label %41
41: ; preds = %38, %33
%42 = load i64, i64* %2
%43 = load i64, i64* %1
%44 = icmp sgt i64 %42, %43
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = load i64, i64* %2
br label %49
47: ; preds = %41
%48 = load i64, i64* %1
br label %49
49: ; preds = %47, %45
%50 = phi i64 [ %46, %45 ], [ %48, %47 ]
store i64 %50, i64* %1
%51 = call i64 @get_sensor_update_interval(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
store i64 %51, i64* %2
%52 = load i64, i64* %2
%53 = icmp slt i64 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %49
%55 = load i32, i32* @stderr
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.7, i64 0, i64 0))
br label %57
57: ; preds = %54, %49
%58 = load i64, i64* %2
%59 = load i64, i64* %1
%60 = icmp sgt i64 %58, %59
br i1 %60, label %61, label %63
61: ; preds = %57
%62 = load i64, i64* %2
br label %65
63: ; preds = %57
%64 = load i64, i64* %1
br label %65
65: ; preds = %63, %61
%66 = phi i64 [ %62, %61 ], [ %64, %63 ]
store i64 %66, i64* %1
%67 = load i64, i64* %1
%68 = icmp eq i64 %67, 0
br i1 %68, label %69, label %73
69: ; preds = %65
store i64 263808, i64* %1
%70 = load i32, i32* @stderr
%71 = load i64, i64* %1
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.8, i64 0, i64 0), i64 %71)
br label %73
73: ; preds = %69, %65
%74 = load i64, i64* %1
ret i64 %74
}

LLVM IR (-O2):
@.str = [7 x i8] c"4-0040\00"
@stderr = global i32 0
@.str.1 = [66 x i8] c"get_update_interval: Warning: could not read A15 update interval\0A\00"
@.str.2 = [7 x i8] c"4-0045\00"
@.str.3 = [65 x i8] c"get_update_interval: Warning: could not read A7 update interval\0A\00"
@.str.4 = [7 x i8] c"4-0041\00"
@.str.5 = [66 x i8] c"get_update_interval: Warning: could not read MEM update interval\0A\00"
@.str.6 = [7 x i8] c"4-0044\00"
@.str.7 = [66 x i8] c"get_update_interval: Warning: could not read GPU update interval\0A\00"
@.str.8 = [50 x i8] c"get_update_interval: Using default value: %ld us\0A\00"
define i64 @get_update_interval() {
%1 = tail call i64 @get_sensor_update_interval(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%2 = icmp slt i64 %1, 0
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = load i32, i32* @stderr
%5 = tail call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.1, i64 0, i64 0))
br label %6
6: ; preds = %3, %0
%7 = icmp sgt i64 %1, 0
%8 = select i1 %7, i64 %1, i64 0
%9 = tail call i64 @get_sensor_update_interval(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.3, i64 0, i64 0))
br label %14
14: ; preds = %11, %6
%15 = icmp sgt i64 %9, %8
%16 = select i1 %15, i64 %9, i64 %8
%17 = tail call i64 @get_sensor_update_interval(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = load i32, i32* @stderr
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.5, i64 0, i64 0))
br label %22
22: ; preds = %19, %14
%23 = icmp sgt i64 %17, %16
%24 = select i1 %23, i64 %17, i64 %16
%25 = tail call i64 @get_sensor_update_interval(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%26 = icmp slt i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = load i32, i32* @stderr
%29 = tail call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.7, i64 0, i64 0))
br label %30
30: ; preds = %27, %22
%31 = icmp sgt i64 %25, %24
%32 = select i1 %31, i64 %25, i64 %24
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %30
%35 = load i32, i32* @stderr
%36 = tail call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.8, i64 0, i64 0), i64 263808)
br label %37
37: ; preds = %34, %30
%38 = phi i64 [ 263808, %34 ], [ %32, %30 ]
ret i64 %38
}