#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 satsys(int, int *);
int to_satid(int sys, int sat) {
  int prn;
  if (satsys(sat, &prn) != sys)
    return 0;
  if (sys == 0x10)
    prn -= 0 - 1;
  else if (sys == 0x02)
    prn -= 120 - 1;
  return prn;
}


x86 assembly (clang, -O0):
<to_satid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   1030 <satsys@plt>
cmp    -0x8(%rbp),%eax
je     113f <to_satid+0x2f>
movl   $0x0,-0x4(%rbp)
jmp    1175 <to_satid+0x65>
cmpl   $0x10,-0x8(%rbp)
jne    1157 <to_satid+0x47>
mov    -0x10(%rbp),%eax
sub    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    116f <to_satid+0x5f>
cmpl   $0x2,-0x8(%rbp)
jne    116a <to_satid+0x5a>
mov    -0x10(%rbp),%eax
sub    $0x77,%eax
mov    %eax,-0x10(%rbp)
jmp    116f <to_satid+0x5f>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<to_satid>:
push   %rbx
sub    $0x10,%rsp
mov    %esi,%eax
mov    %edi,%ebx
lea    0xc(%rsp),%rsi
mov    %eax,%edi
call   1030 <satsys@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ebx,%ecx
jne    114d <to_satid+0x3d>
cmp    $0x2,%ebx
je     1140 <to_satid+0x30>
cmp    $0x10,%ebx
jne    1149 <to_satid+0x39>
mov    0xc(%rsp),%eax
add    $0x1,%eax
jmp    114d <to_satid+0x3d>
mov    0xc(%rsp),%eax
add    $0xffffff89,%eax
jmp    114d <to_satid+0x3d>
mov    0xc(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @to_satid(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = load i32, i32* %5
%8 = call i32 @satsys(i32 %7, i32* %6)
%9 = load i32, i32* %4
%10 = icmp ne i32 %8, %9
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 0, i32* %3
br label %27
12: ; preds = %2
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 16
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i32, i32* %6
%17 = sub nsw i32 %16, -1
store i32 %17, i32* %6
br label %25
18: ; preds = %12
%19 = load i32, i32* %4
%20 = icmp eq i32 %19, 2
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i32, i32* %6
%23 = sub nsw i32 %22, 119
store i32 %23, i32* %6
br label %24
24: ; preds = %21, %18
br label %25
25: ; preds = %24, %15
%26 = load i32, i32* %6
store i32 %26, i32* %3
br label %27
27: ; preds = %25, %11
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
define i32 @to_satid(i32 %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @satsys(i32 %1, i32* %3)
%6 = icmp eq i32 %5, %0
br i1 %6, label %7, label %16
7: ; preds = %2
switch i32 %0, label %8 [
i32 16, label %10
i32 2, label %13
]
8: ; preds = %7
%9 = load i32, i32* %3
br label %16
10: ; preds = %7
%11 = load i32, i32* %3
%12 = add nsw i32 %11, 1
br label %16
13: ; preds = %7
%14 = load i32, i32* %3
%15 = add nsw i32 %14, -119
br label %16
16: ; preds = %10, %13, %8, %2
%17 = phi i32 [ 0, %2 ], [ %9, %8 ], [ %15, %13 ], [ %12, %10 ]
ret i32 %17
}