#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 /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
extern void satno2id(int sat, char *id) {
  int prn;
  switch (satsys(sat, &prn)) {
  case 0x01:
    sprintf(id, "G%02d", prn - 1 + 1);
    return;
  case 0x04:
    sprintf(id, "R%02d", prn - 0 + 1);
    return;
  case 0x08:
    sprintf(id, "E%02d", prn - 0 + 1);
    return;
  case 0x10:
    sprintf(id, "J%02d", prn - 0 + 1);
    return;
  case 0x20:
    sprintf(id, "C%02d", prn - 0 + 1);
    return;
  case 0x02:
    sprintf(id, "%03d", prn);
    return;
  }
  strcpy(id, "");
}


x86 assembly (clang, -O0):
<satno2id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x14(%rbp),%rsi
call   1040 <satsys@plt>
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x1f,%eax
ja     121f <satno2id+0xef>
mov    -0x20(%rbp),%rax
lea    0xe98(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
sub    $0x1,%edx
add    $0x1,%edx
lea    0xefb(%rip),%rsi
call   1050 <sprintf@plt>
jmp    122f <satno2id+0xff>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
sub    $0x0,%edx
add    $0x1,%edx
lea    0xee3(%rip),%rsi
call   1050 <sprintf@plt>
jmp    122f <satno2id+0xff>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
sub    $0x0,%edx
add    $0x1,%edx
lea    0xecb(%rip),%rsi
call   1050 <sprintf@plt>
jmp    122f <satno2id+0xff>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
sub    $0x0,%edx
add    $0x1,%edx
lea    0xeb3(%rip),%rsi
call   1050 <sprintf@plt>
jmp    122f <satno2id+0xff>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
sub    $0x0,%edx
add    $0x1,%edx
lea    0xe9b(%rip),%rsi
call   1050 <sprintf@plt>
jmp    122f <satno2id+0xff>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe89(%rip),%rsi
call   1050 <sprintf@plt>
jmp    122f <satno2id+0xff>
mov    -0x10(%rbp),%rdi
lea    0xe73(%rip),%rsi
call   1030 <strcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<satno2id>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
lea    0xc(%rsp),%rsi
call   1040 <satsys@plt>
add    $0xffffffff,%eax
cmp    $0x1f,%eax
ja     1174 <satno2id+0x44>
lea    0xeaf(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0xc(%rsp),%edx
lea    0xf1b(%rip),%rsi
jmp    11c3 <satno2id+0x93>
mov    0xc(%rsp),%edx
lea    0xf2c(%rip),%rsi
jmp    11c3 <satno2id+0x93>
lea    0xf22(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
jmp    11cb <satno2id+0x9b>
mov    0xc(%rsp),%edx
add    $0x1,%edx
lea    0xef3(%rip),%rsi
jmp    11c3 <satno2id+0x93>
mov    0xc(%rsp),%edx
add    $0x1,%edx
lea    0xee9(%rip),%rsi
jmp    11c3 <satno2id+0x93>
mov    0xc(%rsp),%edx
add    $0x1,%edx
lea    0xedf(%rip),%rsi
jmp    11c3 <satno2id+0x93>
mov    0xc(%rsp),%edx
add    $0x1,%edx
lea    0xed5(%rip),%rsi
mov    %rbx,%rdi
call   1050 <sprintf@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"G%02d\00"
@.str.1 = [6 x i8] c"R%02d\00"
@.str.2 = [6 x i8] c"E%02d\00"
@.str.3 = [6 x i8] c"J%02d\00"
@.str.4 = [6 x i8] c"C%02d\00"
@.str.5 = [5 x i8] c"%03d\00"
@.str.6 = [1 x i8] zeroinitializer
define void @satno2id(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = load i32, i32* %3
%7 = call i32 @satsys(i32 %6, i32* %5)
switch i32 %7, label %42 [
i32 1, label %8
i32 4, label %14
i32 8, label %20
i32 16, label %26
i32 32, label %32
i32 2, label %38
]
8: ; preds = %2
%9 = load i8*, i8** %4
%10 = load i32, i32* %5
%11 = sub nsw i32 %10, 1
%12 = add nsw i32 %11, 1
%13 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %12)
br label %45
14: ; preds = %2
%15 = load i8*, i8** %4
%16 = load i32, i32* %5
%17 = sub nsw i32 %16, 0
%18 = add nsw i32 %17, 1
%19 = call i32 @sprintf(i8* %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %18)
br label %45
20: ; preds = %2
%21 = load i8*, i8** %4
%22 = load i32, i32* %5
%23 = sub nsw i32 %22, 0
%24 = add nsw i32 %23, 1
%25 = call i32 @sprintf(i8* %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %24)
br label %45
26: ; preds = %2
%27 = load i8*, i8** %4
%28 = load i32, i32* %5
%29 = sub nsw i32 %28, 0
%30 = add nsw i32 %29, 1
%31 = call i32 @sprintf(i8* %27, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %30)
br label %45
32: ; preds = %2
%33 = load i8*, i8** %4
%34 = load i32, i32* %5
%35 = sub nsw i32 %34, 0
%36 = add nsw i32 %35, 1
%37 = call i32 @sprintf(i8* %33, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %36)
br label %45
38: ; preds = %2
%39 = load i8*, i8** %4
%40 = load i32, i32* %5
%41 = call i32 @sprintf(i8* %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %40)
br label %45
42: ; preds = %2
%43 = load i8*, i8** %4
%44 = call i32 @strcpy(i8* %43, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0))
br label %45
45: ; preds = %42, %38, %32, %26, %20, %14, %8
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"G%02d\00"
@.str.1 = [6 x i8] c"R%02d\00"
@.str.2 = [6 x i8] c"E%02d\00"
@.str.3 = [6 x i8] c"J%02d\00"
@.str.4 = [6 x i8] c"C%02d\00"
@.str.5 = [5 x i8] c"%03d\00"
@.str.6 = [1 x i8] zeroinitializer
define void @satno2id(i32 %0, i8* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @satsys(i32 %0, i32* %3)
switch i32 %5, label %28 [
i32 1, label %6
i32 4, label %9
i32 8, label %13
i32 16, label %17
i32 32, label %21
i32 2, label %25
]
6: ; preds = %2
%7 = load i32, i32* %3
%8 = call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %30
9: ; preds = %2
%10 = load i32, i32* %3
%11 = add nsw i32 %10, 1
%12 = call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %11)
br label %30
13: ; preds = %2
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
%16 = call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %15)
br label %30
17: ; preds = %2
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
%20 = call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %19)
br label %30
21: ; preds = %2
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
%24 = call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %23)
br label %30
25: ; preds = %2
%26 = load i32, i32* %3
%27 = call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %26)
br label %30
28: ; preds = %2
%29 = call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0))
br label %30
30: ; preds = %28, %25, %21, %17, %13, %9, %6
ret void
}