#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 0x40:
    sprintf(id, "L%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    $0x3f,%eax
ja     123d <satno2id+0x10d>
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    0xf7b(%rip),%rsi
call   1050 <sprintf@plt>
jmp    124d <satno2id+0x11d>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
sub    $0x0,%edx
add    $0x1,%edx
lea    0xf63(%rip),%rsi
call   1050 <sprintf@plt>
jmp    124d <satno2id+0x11d>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
sub    $0x0,%edx
add    $0x1,%edx
lea    0xf4b(%rip),%rsi
call   1050 <sprintf@plt>
jmp    124d <satno2id+0x11d>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
sub    $0x0,%edx
add    $0x1,%edx
lea    0xf33(%rip),%rsi
call   1050 <sprintf@plt>
jmp    124d <satno2id+0x11d>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
sub    $0x0,%edx
add    $0x1,%edx
lea    0xf1b(%rip),%rsi
call   1050 <sprintf@plt>
jmp    124d <satno2id+0x11d>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
sub    $0x0,%edx
add    $0x1,%edx
lea    0xf03(%rip),%rsi
call   1050 <sprintf@plt>
jmp    124d <satno2id+0x11d>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xef1(%rip),%rsi
call   1050 <sprintf@plt>
jmp    124d <satno2id+0x11d>
mov    -0x10(%rbp),%rdi
lea    0xed5(%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    $0x3f,%eax
ja     1174 <satno2id+0x44>
lea    0xeaf(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0xc(%rsp),%edx
lea    0xf9b(%rip),%rsi
jmp    11d3 <satno2id+0xa3>
mov    0xc(%rsp),%edx
lea    0xfb2(%rip),%rsi
jmp    11d3 <satno2id+0xa3>
lea    0xfa2(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
jmp    11db <satno2id+0xab>
mov    0xc(%rsp),%edx
add    $0x1,%edx
lea    0xf73(%rip),%rsi
jmp    11d3 <satno2id+0xa3>
mov    0xc(%rsp),%edx
add    $0x1,%edx
lea    0xf69(%rip),%rsi
jmp    11d3 <satno2id+0xa3>
mov    0xc(%rsp),%edx
add    $0x1,%edx
lea    0xf65(%rip),%rsi
jmp    11d3 <satno2id+0xa3>
mov    0xc(%rsp),%edx
add    $0x1,%edx
lea    0xf5b(%rip),%rsi
jmp    11d3 <satno2id+0xa3>
mov    0xc(%rsp),%edx
add    $0x1,%edx
lea    0xf3f(%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 = [6 x i8] c"L%02d\00"
@.str.6 = [5 x i8] c"%03d\00"
@.str.7 = [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 %48 [
i32 1, label %8
i32 4, label %14
i32 8, label %20
i32 16, label %26
i32 32, label %32
i32 64, label %38
i32 2, label %44
]
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 %51
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 %51
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 %51
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 %51
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 %51
38: ; preds = %2
%39 = load i8*, i8** %4
%40 = load i32, i32* %5
%41 = sub nsw i32 %40, 0
%42 = add nsw i32 %41, 1
%43 = call i32 @sprintf(i8* %39, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %42)
br label %51
44: ; preds = %2
%45 = load i8*, i8** %4
%46 = load i32, i32* %5
%47 = call i32 @sprintf(i8* %45, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 %46)
br label %51
48: ; preds = %2
%49 = load i8*, i8** %4
%50 = call i32 @strcpy(i8* %49, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0))
br label %51
51: ; preds = %48, %44, %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 = [6 x i8] c"L%02d\00"
@.str.6 = [5 x i8] c"%03d\00"
@.str.7 = [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 %32 [
i32 1, label %6
i32 4, label %9
i32 8, label %13
i32 16, label %17
i32 32, label %21
i32 64, label %25
i32 2, label %29
]
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 %34
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 %34
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 %34
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 %34
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 %34
25: ; preds = %2
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
%28 = call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %27)
br label %34
29: ; preds = %2
%30 = load i32, i32* %3
%31 = call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 %30)
br label %34
32: ; preds = %2
%33 = call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0))
br label %34
34: ; preds = %32, %29, %25, %21, %17, %13, %9, %6
ret void
}