#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*/ FS460_image_request_freeze(int, int, int /*<<< orphan*/);
int /*<<< orphan*/ write_fram(int);
void pattern_test(void) {
  static int mode = 0;
  switch (mode++) {
  default:
    mode = 1;
  case 0:
    FS460_image_request_freeze(0x0001, 0x0001, 0);
    break;
  case 1:
    write_fram(0);
    break;
  case 2:
    FS460_image_request_freeze(0, 0x0001, 0);
    break;
  case 3:
    FS460_image_request_freeze(0x0001, 0x0001, 0);
    break;
  case 4:
    write_fram(1);
    break;
  case 5:
    FS460_image_request_freeze(0, 0x0001, 0);
    break;
  }
}


x86 assembly (clang, -O0):
<pattern_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2f06(%rip),%eax
mov    %eax,%ecx
mov    %rcx,-0x8(%rbp)
mov    %ecx,%eax
add    $0x1,%eax
sub    $0x5,%rcx
mov    %eax,0x2ef1(%rip)
ja     115d <pattern_test+0x3d>
mov    -0x8(%rbp),%rax
lea    0xeac(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,0x2ecd(%rip)
mov    $0x1,%esi
xor    %edx,%edx
mov    %esi,%edi
call   1030 <FS460_image_request_freeze@plt>
jmp    11c9 <pattern_test+0xa9>
xor    %edi,%edi
call   1040 <write_fram@plt>
jmp    11c9 <pattern_test+0xa9>
xor    %edx,%edx
mov    $0x1,%esi
mov    %edx,%edi
call   1030 <FS460_image_request_freeze@plt>
jmp    11c9 <pattern_test+0xa9>
mov    $0x1,%esi
xor    %edx,%edx
mov    %esi,%edi
call   1030 <FS460_image_request_freeze@plt>
jmp    11c9 <pattern_test+0xa9>
mov    $0x1,%edi
call   1040 <write_fram@plt>
jmp    11c9 <pattern_test+0xa9>
xor    %edx,%edx
mov    $0x1,%esi
mov    %edx,%edi
call   1030 <FS460_image_request_freeze@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pattern_test>:
mov    0x2f0e(%rip),%eax
lea    0x1(%rax),%ecx
mov    %ecx,0x2f05(%rip)
cmp    $0x5,%rax
ja     1149 <pattern_test+0x29>
lea    0xec4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %edi,%edi
jmp    1158 <pattern_test+0x38>
movl   $0x1,0x2ee1(%rip)
mov    $0x1,%edi
mov    $0x1,%esi
xor    %edx,%edx
jmp    1030 <FS460_image_request_freeze@plt>
xor    %edi,%edi
jmp    1040 <write_fram@plt>
mov    $0x1,%edi
jmp    1040 <write_fram@plt>

LLVM IR (-O0):
@pattern_test.mode = internal global i32 0
define void @pattern_test() {
%1 = load i32, i32* @pattern_test.mode
%2 = add nsw i32 %1, 1
store i32 %2, i32* @pattern_test.mode
switch i32 %1, label %3 [
i32 0, label %4
i32 1, label %6
i32 2, label %8
i32 3, label %10
i32 4, label %12
i32 5, label %14
]
3: ; preds = %0
store i32 1, i32* @pattern_test.mode
br label %4
4: ; preds = %0, %3
%5 = call i32 @FS460_image_request_freeze(i32 1, i32 1, i32 0)
br label %16
6: ; preds = %0
%7 = call i32 @write_fram(i32 0)
br label %16
8: ; preds = %0
%9 = call i32 @FS460_image_request_freeze(i32 0, i32 1, i32 0)
br label %16
10: ; preds = %0
%11 = call i32 @FS460_image_request_freeze(i32 1, i32 1, i32 0)
br label %16
12: ; preds = %0
%13 = call i32 @write_fram(i32 1)
br label %16
14: ; preds = %0
%15 = call i32 @FS460_image_request_freeze(i32 0, i32 1, i32 0)
br label %16
16: ; preds = %14, %12, %10, %8, %6, %4
ret void
}

LLVM IR (-O2):
@pattern_test.mode = internal unnamed_addr global i32 0
define void @pattern_test() {
%1 = load i32, i32* @pattern_test.mode
%2 = add nsw i32 %1, 1
store i32 %2, i32* @pattern_test.mode
switch i32 %1, label %3 [
i32 0, label %4
i32 1, label %6
i32 2, label %8
i32 3, label %10
i32 4, label %12
i32 5, label %14
]
3: ; preds = %0
store i32 1, i32* @pattern_test.mode
br label %4
4: ; preds = %0, %3
%5 = tail call i32 @FS460_image_request_freeze(i32 1, i32 1, i32 0)
br label %16
6: ; preds = %0
%7 = tail call i32 @write_fram(i32 0)
br label %16
8: ; preds = %0
%9 = tail call i32 @FS460_image_request_freeze(i32 0, i32 1, i32 0)
br label %16
10: ; preds = %0
%11 = tail call i32 @FS460_image_request_freeze(i32 1, i32 1, i32 0)
br label %16
12: ; preds = %0
%13 = tail call i32 @write_fram(i32 1)
br label %16
14: ; preds = %0
%15 = tail call i32 @FS460_image_request_freeze(i32 0, i32 1, i32 0)
br label %16
16: ; preds = %14, %12, %10, %8, %6, %4
ret void
}