#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*/ DisplayOptions(char *, char *, char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
void ShoppingItems() {
  int choice = -1;
  puts("What would you like to buy:");
  puts("1 - shoes, 2 - T shirts, 3 - trousers, 4 - dresses, 5 - nothing, I am "
       "just looking around");
  scanf("%d", &choice);
  switch (choice) {
  case 1:
    DisplayOptions("Nike", "Adidas", "UA");
    break;
  case 2:
    DisplayOptions("Puma", "Reebok", "CK");
    break;
  case 3:
    DisplayOptions("Massimo", "Zara", "Pull&Bear");
    break;
  case 4:
    DisplayOptions("Zara", "Massimo", "Channel");
    break;
  case 5:
    puts("Hurry up and buy!");
    break;
  default:
    break;
  }
}


x86 assembly (clang, -O0):
<ShoppingItems>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0xffffffff,-0x4(%rbp)
lea    0xece(%rip),%rdi
call   1030 <puts@plt>
lea    0xede(%rip),%rdi
call   1030 <puts@plt>
lea    0xf2c(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x4,%eax
ja     121d <ShoppingItems+0xed>
mov    -0x10(%rbp),%rax
lea    0xe79(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xef6(%rip),%rdi
lea    0xef4(%rip),%rsi
lea    0xef4(%rip),%rdx
call   1040 <DisplayOptions@plt>
jmp    1222 <ShoppingItems+0xf2>
lea    0xee6(%rip),%rdi
lea    0xee4(%rip),%rsi
lea    0xee4(%rip),%rdx
call   1040 <DisplayOptions@plt>
jmp    1222 <ShoppingItems+0xf2>
lea    0xed6(%rip),%rdi
lea    0xed7(%rip),%rsi
lea    0xed5(%rip),%rdx
call   1040 <DisplayOptions@plt>
jmp    1222 <ShoppingItems+0xf2>
lea    0xebf(%rip),%rdi
lea    0xeb0(%rip),%rsi
lea    0xec0(%rip),%rdx
call   1040 <DisplayOptions@plt>
jmp    1222 <ShoppingItems+0xf2>
lea    0xeb7(%rip),%rdi
call   1030 <puts@plt>
jmp    1222 <ShoppingItems+0xf2>
jmp    1222 <ShoppingItems+0xf2>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ShoppingItems>:
push   %rax
movl   $0xffffffff,0x4(%rsp)
ff
lea    0xed4(%rip),%rdi
call   1030 <puts@plt>
lea    0xee4(%rip),%rdi
call   1030 <puts@plt>
lea    0xf32(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x4,%eax
ja     11eb <ShoppingItems+0xbb>
lea    0xe8b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf08(%rip),%rdi
lea    0xf06(%rip),%rsi
lea    0xf06(%rip),%rdx
jmp    11d8 <ShoppingItems+0xa8>
lea    0xf00(%rip),%rdi
lea    0xefe(%rip),%rsi
lea    0xefe(%rip),%rdx
jmp    11d8 <ShoppingItems+0xa8>
lea    0xef8(%rip),%rdi
lea    0xef9(%rip),%rsi
lea    0xef7(%rip),%rdx
jmp    11d8 <ShoppingItems+0xa8>
lea    0xee9(%rip),%rdi
lea    0xeda(%rip),%rsi
lea    0xeea(%rip),%rdx
call   1040 <DisplayOptions@plt>
pop    %rax
ret
lea    0xee4(%rip),%rdi
call   1030 <puts@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [28 x i8] c"What would you like to buy:\00"
@.str.1 = [90 x i8] c"1 - shoes, 2 - T shirts, 3 - trousers, 4 - dresses, 5 - nothing, I am just looking around\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [5 x i8] c"Nike\00"
@.str.4 = [7 x i8] c"Adidas\00"
@.str.5 = [3 x i8] c"UA\00"
@.str.6 = [5 x i8] c"Puma\00"
@.str.7 = [7 x i8] c"Reebok\00"
@.str.8 = [3 x i8] c"CK\00"
@.str.9 = [8 x i8] c"Massimo\00"
@.str.10 = [5 x i8] c"Zara\00"
@.str.11 = [10 x i8] c"Pull&Bear\00"
@.str.12 = [8 x i8] c"Channel\00"
@.str.13 = [18 x i8] c"Hurry up and buy!\00"
define void @ShoppingItems() {
%1 = alloca i32
store i32 -1, i32* %1
%2 = call i32 @puts(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @puts(i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
switch i32 %5, label %16 [
i32 1, label %6
i32 2, label %8
i32 3, label %10
i32 4, label %12
i32 5, label %14
]
6: ; preds = %0
%7 = call i32 @DisplayOptions(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %17
8: ; preds = %0
%9 = call i32 @DisplayOptions(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
br label %17
10: ; preds = %0
%11 = call i32 @DisplayOptions(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0))
br label %17
12: ; preds = %0
%13 = call i32 @DisplayOptions(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0))
br label %17
14: ; preds = %0
%15 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.13, i64 0, i64 0))
br label %17
16: ; preds = %0
br label %17
17: ; preds = %16, %14, %12, %10, %8, %6
ret void
}

LLVM IR (-O2):
@.str = [28 x i8] c"What would you like to buy:\00"
@.str.1 = [90 x i8] c"1 - shoes, 2 - T shirts, 3 - trousers, 4 - dresses, 5 - nothing, I am just looking around\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [5 x i8] c"Nike\00"
@.str.4 = [7 x i8] c"Adidas\00"
@.str.5 = [3 x i8] c"UA\00"
@.str.6 = [5 x i8] c"Puma\00"
@.str.7 = [7 x i8] c"Reebok\00"
@.str.8 = [3 x i8] c"CK\00"
@.str.9 = [8 x i8] c"Massimo\00"
@.str.10 = [5 x i8] c"Zara\00"
@.str.11 = [10 x i8] c"Pull&Bear\00"
@.str.12 = [8 x i8] c"Channel\00"
@.str.13 = [18 x i8] c"Hurry up and buy!\00"
define void @ShoppingItems() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 -1, i32* %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([90 x i8], [90 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
switch i32 %6, label %17 [
i32 1, label %7
i32 2, label %9
i32 3, label %11
i32 4, label %13
i32 5, label %15
]
7: ; preds = %0
%8 = call i32 @DisplayOptions(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %17
9: ; preds = %0
%10 = call i32 @DisplayOptions(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
br label %17
11: ; preds = %0
%12 = call i32 @DisplayOptions(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0))
br label %17
13: ; preds = %0
%14 = call i32 @DisplayOptions(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0))
br label %17
15: ; preds = %0
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.13, i64 0, i64 0))
br label %17
17: ; preds = %0, %15, %13, %11, %9, %7
ret void
}