#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*/ printf(char *);
int s2frames(int, int, unsigned char, char *);
int frameString(int mode, unsigned char devid, char *sourceBuf) {
  if (sourceBuf == NULL)
    return 0;
  printf(
      "frame.c: frameString() -> deciding what priority the frame will be.\n");
  switch (mode) {
  case 3:
    return s2frames(0x01, 0x41, devid, sourceBuf);
    break;
  case 2:
    return s2frames(0x02, 0x41, devid, sourceBuf);
    break;
  case 1:
    return s2frames(0x03, 0x41, devid, sourceBuf);
    break;
  }
}


x86 assembly (clang, -O0):
<frameString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %edi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    114c <frameString+0x2c>
movl   $0x0,-0x4(%rbp)
jmp    11ec <frameString+0xcc>
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x1,%eax
je     11d0 <frameString+0xb0>
jmp    116c <frameString+0x4c>
mov    -0x1c(%rbp),%eax
sub    $0x2,%eax
je     11af <frameString+0x8f>
jmp    117d <frameString+0x5d>
mov    -0x1c(%rbp),%eax
sub    $0x3,%eax
jne    11ec <frameString+0xcc>
jmp    118e <frameString+0x6e>
mov    -0x9(%rbp),%al
mov    -0x18(%rbp),%rcx
mov    $0x1,%edi
mov    $0x41,%esi
movzbl %al,%edx
call   1040 <s2frames@plt>
mov    %eax,-0x4(%rbp)
jmp    11ec <frameString+0xcc>
mov    -0x9(%rbp),%al
mov    -0x18(%rbp),%rcx
mov    $0x2,%edi
mov    $0x41,%esi
movzbl %al,%edx
call   1040 <s2frames@plt>
mov    %eax,-0x4(%rbp)
jmp    11ec <frameString+0xcc>
mov    -0x9(%rbp),%al
mov    -0x18(%rbp),%rcx
mov    $0x3,%edi
mov    $0x41,%esi
movzbl %al,%edx
call   1040 <s2frames@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<frameString>:
push   %rbp
push   %r14
push   %rbx
test   %rdx,%rdx
je     1161 <frameString+0x41>
mov    %rdx,%rbx
mov    %esi,%r14d
mov    %edi,%ebp
lea    0xec8(%rip),%rdi
call   1030 <puts@plt>
lea    -0x1(%rbp),%eax
cmp    $0x2,%eax
ja     1161 <frameString+0x41>
mov    $0x4,%edi
sub    %ebp,%edi
movzbl %r14b,%edx
mov    $0x41,%esi
mov    %rbx,%rcx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <s2frames@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [69 x i8] c"frame.c: frameString() -> deciding what priority the frame will be.\0A\00"
define i32 @frameString(i32 %0, i8 zeroext %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
%7 = alloca i8*
store i32 %0, i32* %5
store i8 %1, i8* %6
store i8* %2, i8** %7
%8 = load i8*, i8** %7
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %11
10: ; preds = %3
store i32 0, i32* %4
br label %26
11: ; preds = %3
%12 = call i32 @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* %5
switch i32 %13, label %26 [
i32 3, label %14
i32 2, label %18
i32 1, label %22
]
14: ; preds = %11
%15 = load i8, i8* %6
%16 = load i8*, i8** %7
%17 = call i32 @s2frames(i32 1, i32 65, i8 zeroext %15, i8* %16)
store i32 %17, i32* %4
br label %26
18: ; preds = %11
%19 = load i8, i8* %6
%20 = load i8*, i8** %7
%21 = call i32 @s2frames(i32 2, i32 65, i8 zeroext %19, i8* %20)
store i32 %21, i32* %4
br label %26
22: ; preds = %11
%23 = load i8, i8* %6
%24 = load i8*, i8** %7
%25 = call i32 @s2frames(i32 3, i32 65, i8 zeroext %23, i8* %24)
store i32 %25, i32* %4
br label %26
26: ; preds = %10, %14, %18, %22, %11
%27 = load i32, i32* %4
ret i32 %27
}

LLVM IR (-O2):
@str = [68 x i8] c"frame.c: frameString() -> deciding what priority the frame will be.\00"
define i32 @frameString(i32 %0, i8 zeroext %1, i8* %2) {
%4 = icmp eq i8* %2, null
br i1 %4, label %12, label %5
5: ; preds = %3
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @str, i64 0, i64 0))
%7 = add i32 %0, -1
%8 = icmp ult i32 %7, 3
br i1 %8, label %9, label %12
9: ; preds = %5
%10 = sub i32 4, %0
%11 = tail call i32 @s2frames(i32 %10, i32 65, i8 zeroext %1, i8* %2)
br label %12
12: ; preds = %5, %9, %3
%13 = phi i32 [ undef, %5 ], [ 0, %3 ], [ %11, %9 ]
ret i32 %13
}