#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 g(int);
int /*<<< orphan*/ printf(char *);
int f(int j) {
  int i;
  switch (j) {
  case 3:
    i = g(j);
    printf("3");
  case 4:
    if (i == 3) {
      printf("hullo");
      return 3;
    } else {
      printf("yabba");
      break;
    }
  case 5:
    i = g(j++);
    while (i < 3) {
      i++;
      if (j == 4)
        break;
    }
  case 6:
    printf("high");
    return 3;
  case 7:
  case 8:
  case 9:
    printf("nope");
  default:
    printf("splat");
  }
}


x86 assembly (clang, -O0):
<f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0xfffffffd,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x6,%eax
ja     1201 <f+0xe1>
mov    -0x18(%rbp),%rax
lea    0xeb5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%edi
call   1040 <g@plt>
mov    %eax,-0xc(%rbp)
lea    0xeb6(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x3,-0xc(%rbp)
jne    118d <f+0x6d>
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
movl   $0x3,-0x4(%rbp)
jmp    120d <f+0xed>
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
jmp    120d <f+0xed>
mov    -0x8(%rbp),%edi
mov    %edi,%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
call   1040 <g@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jge    11d8 <f+0xb8>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x4,-0x8(%rbp)
jne    11d3 <f+0xb3>
jmp    11d8 <f+0xb8>
jmp    11b1 <f+0x91>
jmp    11dd <f+0xbd>
lea    0xe46(%rip),%rdi
call   1030 <printf@plt>
movl   $0x3,-0x4(%rbp)
jmp    120d <f+0xed>
lea    0xe33(%rip),%rdi
call   1030 <printf@plt>
lea    0xe2c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f>:
push   %rbx
mov    %edi,%eax
add    $0xfffffffd,%eax
cmp    $0x6,%eax
ja     115e <f+0x2e>
lea    0xeda(%rip),%rdi
lea    0xeb7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xed4(%rip),%rdi
call   1040 <printf@plt>
lea    0xecd(%rip),%rdi
jmp    11a5 <f+0x75>
mov    $0x3,%edi
call   1050 <g@plt>
mov    %eax,%ebx
mov    $0x33,%edi
call   1030 <putchar@plt>
cmp    $0x3,%ebx
lea    0xe95(%rip),%rax
lea    0xe94(%rip),%rdi
cmove  %rax,%rdi
jmp    11a5 <f+0x75>
mov    $0x5,%edi
call   1050 <g@plt>
lea    0xe83(%rip),%rdi
call   1040 <printf@plt>
mov    $0x3,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"3\00"
@.str.1 = [6 x i8] c"hullo\00"
@.str.2 = [6 x i8] c"yabba\00"
@.str.3 = [5 x i8] c"high\00"
@.str.4 = [5 x i8] c"nope\00"
@.str.5 = [6 x i8] c"splat\00"
define i32 @f(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
switch i32 %5, label %36 [
i32 3, label %6
i32 4, label %10
i32 5, label %17
i32 6, label %32
i32 7, label %34
i32 8, label %34
i32 9, label %34
]
6: ; preds = %1
%7 = load i32, i32* %3
%8 = call i32 @g(i32 %7)
store i32 %8, i32* %4
%9 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %1, %6
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 3
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 3, i32* %2
br label %38
15: ; preds = %10
%16 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %38
17: ; preds = %1
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
%20 = call i32 @g(i32 %18)
store i32 %20, i32* %4
br label %21
21: ; preds = %30, %17
%22 = load i32, i32* %4
%23 = icmp slt i32 %22, 3
br i1 %23, label %24, label %31
24: ; preds = %21
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
%27 = load i32, i32* %3
%28 = icmp eq i32 %27, 4
br i1 %28, label %29, label %30
29: ; preds = %24
br label %31
30: ; preds = %24
br label %21
31: ; preds = %29, %21
br label %32
32: ; preds = %1, %31
%33 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
store i32 3, i32* %2
br label %38
34: ; preds = %1, %1, %1
%35 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %36
36: ; preds = %1, %34
%37 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %38
38: ; preds = %13, %32, %36, %15
%39 = load i32, i32* %2
ret i32 %39
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"hullo\00"
@.str.2 = [6 x i8] c"yabba\00"
@.str.3 = [5 x i8] c"high\00"
@.str.4 = [5 x i8] c"nope\00"
@.str.5 = [6 x i8] c"splat\00"
define i32 @f(i32 %0) {
switch i32 %0, label %12 [
i32 3, label %2
i32 4, label %13
i32 5, label %7
i32 6, label %9
i32 7, label %10
i32 8, label %10
i32 9, label %10
]
2: ; preds = %1
%3 = tail call i32 @g(i32 3)
%4 = tail call i32 @putchar(i32 51)
%5 = icmp eq i32 %3, 3
%6 = select i1 %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0)
br label %13
7: ; preds = %1
%8 = tail call i32 @g(i32 5)
br label %9
9: ; preds = %7, %1
br label %13
10: ; preds = %1, %1, %1
%11 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %12
12: ; preds = %1, %10
br label %13
13: ; preds = %2, %1, %12, %9
%14 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), %12 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %9 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), %1 ], [ %6, %2 ]
%15 = tail call i32 @printf(i8* dereferenceable(1) %14)
ret i32 3
}