#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 */
typedef int /*<<< orphan*/ tempString;

/* Variables and functions */
int setStandardProcedure(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int setSiteName(char *siteName, int siteNum) {
  char tempString[16];
  switch (siteNum) {
  case 1:
    snprintf(tempString, sizeof(tempString), "#:SM %s#", siteName);
    break;
  case 2:
    snprintf(tempString, sizeof(tempString), "#:SN %s#", siteName);
    break;
  case 3:
    snprintf(tempString, sizeof(tempString), "#:SO %s#", siteName);
    break;
  case 4:
    snprintf(tempString, sizeof(tempString), "#:SP %s#", siteName);
    break;
  default:
    return -1;
  }
  return (setStandardProcedure(tempString));
}


x86 assembly (clang, -O0):
<setSiteName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x3,%eax
ja     11d0 <setSiteName+0xb0>
mov    -0x38(%rbp),%rax
lea    0xeb1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x10,%esi
lea    0xea4(%rip),%rdx
call   1040 <snprintf@plt>
jmp    11dc <setSiteName+0xbc>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x10,%esi
lea    0xe8f(%rip),%rdx
call   1040 <snprintf@plt>
jmp    11dc <setSiteName+0xbc>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x10,%esi
lea    0xe7a(%rip),%rdx
call   1040 <snprintf@plt>
jmp    11dc <setSiteName+0xbc>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x10,%esi
lea    0xe65(%rip),%rdx
call   1040 <snprintf@plt>
jmp    11dc <setSiteName+0xbc>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e8 <setSiteName+0xc8>
lea    -0x30(%rbp),%rdi
call   1030 <setStandardProcedure@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setSiteName>:
add    $0xffffffff,%esi
mov    $0xffffffff,%eax
cmp    $0x3,%esi
ja     1163 <setSiteName+0x43>
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rcx
movslq %esi,%rax
lea    0xee5(%rip),%rsi
movslq (%rsi,%rax,4),%rdx
add    %rsi,%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x10,%esi
call   1040 <snprintf@plt>
mov    %rbx,%rdi
call   1030 <setStandardProcedure@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"#:SM %s#\00"
@.str.1 = [9 x i8] c"#:SN %s#\00"
@.str.2 = [9 x i8] c"#:SO %s#\00"
@.str.3 = [9 x i8] c"#:SP %s#\00"
define i32 @setSiteName(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [16 x i8]
store i8* %0, i8** %4
store i32 %1, i32* %5
%7 = load i32, i32* %5
switch i32 %7, label %24 [
i32 1, label %8
i32 2, label %12
i32 3, label %16
i32 4, label %20
]
8: ; preds = %2
%9 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%10 = load i8*, i8** %4
%11 = call i32 @snprintf(i8* %9, i32 16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %25
12: ; preds = %2
%13 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%14 = load i8*, i8** %4
%15 = call i32 @snprintf(i8* %13, i32 16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %25
16: ; preds = %2
%17 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%18 = load i8*, i8** %4
%19 = call i32 @snprintf(i8* %17, i32 16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %18)
br label %25
20: ; preds = %2
%21 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%22 = load i8*, i8** %4
%23 = call i32 @snprintf(i8* %21, i32 16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %22)
br label %25
24: ; preds = %2
store i32 -1, i32* %3
br label %28
25: ; preds = %20, %16, %12, %8
%26 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%27 = call i32 @setStandardProcedure(i8* %26)
store i32 %27, i32* %3
br label %28
28: ; preds = %25, %24
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
@.str = [9 x i8] c"#:SM %s#\00"
@.str.1 = [9 x i8] c"#:SN %s#\00"
@.str.2 = [9 x i8] c"#:SO %s#\00"
@.str.3 = [9 x i8] c"#:SP %s#\00"
@reltable.setSiteName = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str to i64), i64 ptrtoint ([4 x i32]* @reltable.setSiteName to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.setSiteName to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.setSiteName to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.setSiteName to i64)) to i32)]
define i32 @setSiteName(i8* %0, i32 %1) {
%3 = alloca [16 x i8]
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%5 = add i32 %1, -1
%6 = icmp ult i32 %5, 4
br i1 %6, label %7, label %13
7: ; preds = %2
%8 = sext i32 %5 to i64
%9 = shl i64 %8, 2
%10 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.setSiteName to i8*), i64 %9)
%11 = call i32 @snprintf(i8* %4, i32 16, i8* %10, i8* %0)
%12 = call i32 @setStandardProcedure(i8* %4)
br label %13
13: ; preds = %2, %7
%14 = phi i32 [ %12, %7 ], [ -1, %2 ]
ret i32 %14
}