#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int sctp_setPrimary(unsigned int, short);
int /*<<< orphan*/ stderr;
short SCTP_setPrimary(unsigned int associationID, short path_id) {
  int result;
  if ((result = sctp_setPrimary(associationID, path_id)) != 0) {
    if (result == -1) {
      fprintf(stderr, "sctp_setPrimary: library not initialized.\n");
    } else if (result == -3) {
      fprintf(stderr, "sctp_setPrimary: association not found.\n");
    } else if (result == -5) {
      fprintf(stderr, "sctp_setPrimary: internal error.\n");
    } else if (result == -10) {
      fprintf(stderr, "sctp_setPrimary: internal error (data structure not yet "
                      "allocated).\n");
    } else if (result == -4) {
      fprintf(stderr, "sctp_setPrimary: Path Id invalid.\n");
    } else if (result == 1) {
      fprintf(stderr, "sctp_setPrimary: association is not in state "
                      "established, or primary path inactive\n");
    }
    fflush(stderr);
  }
  return result;
}


x86 assembly (clang, -O0):
<SCTP_setPrimary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %si,%ax
mov    %edi,-0x4(%rbp)
mov    %ax,-0x6(%rbp)
mov    -0x4(%rbp),%edi
movswl -0x6(%rbp),%esi
call   1030 <sctp_setPrimary@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
je     1254 <SCTP_setPrimary+0x124>
cmpl   $0xffffffff,-0xc(%rbp)
jne    117e <SCTP_setPrimary+0x4e>
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
lea    0xe8c(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1246 <SCTP_setPrimary+0x116>
cmpl   $0xfffffffd,-0xc(%rbp)
jne    11a2 <SCTP_setPrimary+0x72>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
lea    0xe93(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1241 <SCTP_setPrimary+0x111>
cmpl   $0xfffffffb,-0xc(%rbp)
jne    11c6 <SCTP_setPrimary+0x96>
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
call   1040 <fprintf@plt>
jmp    123c <SCTP_setPrimary+0x10c>
cmpl   $0xfffffff6,-0xc(%rbp)
jne    11ea <SCTP_setPrimary+0xba>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
lea    0xe96(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1237 <SCTP_setPrimary+0x107>
cmpl   $0xfffffffc,-0xc(%rbp)
jne    120e <SCTP_setPrimary+0xde>
mov    0x2de5(%rip),%rax
mov    (%rax),%edi
lea    0xeb7(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1232 <SCTP_setPrimary+0x102>
cmpl   $0x1,-0xc(%rbp)
jne    122d <SCTP_setPrimary+0xfd>
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
lea    0xeb6(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1232 <SCTP_setPrimary+0x102>
jmp    1237 <SCTP_setPrimary+0x107>
jmp    123c <SCTP_setPrimary+0x10c>
jmp    1241 <SCTP_setPrimary+0x111>
jmp    1246 <SCTP_setPrimary+0x116>
mov    0x2d93(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    -0xc(%rbp),%eax
cwtl
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SCTP_setPrimary>:
push   %rbx
call   1030 <sctp_setPrimary@plt>
mov    %eax,%ebx
add    $0xa,%eax
cmp    $0xb,%eax
ja     1190 <SCTP_setPrimary+0x60>
lea    0xee9(%rip),%rsi
lea    0xeb2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf48(%rip),%rsi
jmp    1182 <SCTP_setPrimary+0x52>
lea    0xf1d(%rip),%rsi
jmp    1182 <SCTP_setPrimary+0x52>
lea    0xeeb(%rip),%rsi
jmp    1182 <SCTP_setPrimary+0x52>
lea    0xf95(%rip),%rsi
jmp    1182 <SCTP_setPrimary+0x52>
lea    0xf69(%rip),%rsi
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
call   1040 <fprintf@plt>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [43 x i8] c"sctp_setPrimary: library not initialized.\0A\00"
@.str.1 = [41 x i8] c"sctp_setPrimary: association not found.\0A\00"
@.str.2 = [34 x i8] c"sctp_setPrimary: internal error.\0A\00"
@.str.3 = [69 x i8] c"sctp_setPrimary: internal error (data structure not yet allocated).\0A\00"
@.str.4 = [35 x i8] c"sctp_setPrimary: Path Id invalid.\0A\00"
@.str.5 = [84 x i8] c"sctp_setPrimary: association is not in state established, or primary path inactive\0A\00"
define signext i16 @SCTP_setPrimary(i32 %0, i16 signext %1) {
%3 = alloca i32
%4 = alloca i16
%5 = alloca i32
store i32 %0, i32* %3
store i16 %1, i16* %4
%6 = load i32, i32* %3
%7 = load i16, i16* %4
%8 = call i32 @sctp_setPrimary(i32 %6, i16 signext %7)
store i32 %8, i32* %5
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %54
10: ; preds = %2
%11 = load i32, i32* %5
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
br label %51
16: ; preds = %10
%17 = load i32, i32* %5
%18 = icmp eq i32 %17, -3
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
br label %50
22: ; preds = %16
%23 = load i32, i32* %5
%24 = icmp eq i32 %23, -5
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
br label %49
28: ; preds = %22
%29 = load i32, i32* %5
%30 = icmp eq i32 %29, -10
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = load i32, i32* @stderr
%33 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.3, i64 0, i64 0))
br label %48
34: ; preds = %28
%35 = load i32, i32* %5
%36 = icmp eq i32 %35, -4
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load i32, i32* @stderr
%39 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
br label %47
40: ; preds = %34
%41 = load i32, i32* %5
%42 = icmp eq i32 %41, 1
br i1 %42, label %43, label %46
43: ; preds = %40
%44 = load i32, i32* @stderr
%45 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([84 x i8], [84 x i8]* @.str.5, i64 0, i64 0))
br label %46
46: ; preds = %43, %40
br label %47
47: ; preds = %46, %37
br label %48
48: ; preds = %47, %31
br label %49
49: ; preds = %48, %25
br label %50
50: ; preds = %49, %19
br label %51
51: ; preds = %50, %13
%52 = load i32, i32* @stderr
%53 = call i32 @fflush(i32 %52)
br label %54
54: ; preds = %51, %2
%55 = load i32, i32* %5
%56 = trunc i32 %55 to i16
ret i16 %56
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [43 x i8] c"sctp_setPrimary: library not initialized.\0A\00"
@.str.1 = [41 x i8] c"sctp_setPrimary: association not found.\0A\00"
@.str.2 = [34 x i8] c"sctp_setPrimary: internal error.\0A\00"
@.str.3 = [69 x i8] c"sctp_setPrimary: internal error (data structure not yet allocated).\0A\00"
@.str.4 = [35 x i8] c"sctp_setPrimary: Path Id invalid.\0A\00"
@.str.5 = [84 x i8] c"sctp_setPrimary: association is not in state established, or primary path inactive\0A\00"
define signext i16 @SCTP_setPrimary(i32 %0, i16 signext %1) {
%3 = tail call i32 @sctp_setPrimary(i32 %0, i16 signext %1)
switch i32 %3, label %13 [
i32 0, label %16
i32 -1, label %9
i32 -3, label %4
i32 -5, label %5
i32 -10, label %6
i32 -4, label %7
i32 1, label %8
]
4: ; preds = %2
br label %9
5: ; preds = %2
br label %9
6: ; preds = %2
br label %9
7: ; preds = %2
br label %9
8: ; preds = %2
br label %9
9: ; preds = %2, %5, %7, %8, %6, %4
%10 = phi i8* [ getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), %4 ], [ getelementptr inbounds ([69 x i8], [69 x i8]* @.str.3, i64 0, i64 0), %6 ], [ getelementptr inbounds ([84 x i8], [84 x i8]* @.str.5, i64 0, i64 0), %8 ], [ getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), %7 ], [ getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), %5 ], [ getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), %2 ]
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* %10)
br label %13
13: ; preds = %9, %2
%14 = load i32, i32* @stderr
%15 = tail call i32 @fflush(i32 %14)
br label %16
16: ; preds = %2, %13
%17 = trunc i32 %3 to i16
ret i16 %17
}