#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*/ fgets(char *, int, int /*<<< orphan*/);
int matches(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stdin;
int unmatched(char *, char *);
int main(void) {
  char string[100];
  char group[20];
  int option;
  puts("\nSay something nice");
  fgets(string, 100, stdin);
  puts("\nNow.. What do you want to search from?");
  fgets(group, 20, stdin);
  puts("\nDo you want to count the chars that are repeated - [1]");
  puts("\tor the ones that do not repeat - [2] ?");
  printf("Your option [1] / [2] : ");
  scanf("%d", &option);
  switch (option) {
  case 1:
    printf("\nCool! So there are %d chars repeated!\n", matches(string, group));
  case 2:
    printf("\nCool! So there are %d chars that don't repeat!\n",
           unmatched(string, group));
  default:
    puts("\n1 or 2.\n\tTough choice huh? :-|");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e63(%rip),%rax
mov    %rax,-0xa0(%rbp)
mov    (%rax),%edx
lea    -0x70(%rbp),%rdi
mov    $0x64,%esi
call   1060 <fgets@plt>
lea    0xe71(%rip),%rdi
call   1030 <puts@plt>
mov    -0xa0(%rbp),%rax
mov    (%rax),%edx
lea    -0x90(%rbp),%rdi
mov    $0x14,%esi
call   1060 <fgets@plt>
lea    0xe73(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9f(%rip),%rdi
call   1030 <puts@plt>
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xec6(%rip),%rdi
lea    -0x94(%rbp),%rsi
call   1080 <scanf@plt>
mov    -0x94(%rbp),%eax
mov    %eax,-0x98(%rbp)
sub    $0x1,%eax
je     1229 <main+0xc9>
jmp    1215 <main+0xb5>
mov    -0x98(%rbp),%eax
sub    $0x2,%eax
je     1249 <main+0xe9>
jmp    1269 <main+0x109>
lea    -0x70(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   1040 <matches@plt>
mov    %eax,%esi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x70(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   1070 <unmatched@plt>
mov    %eax,%esi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xea1(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0xa0,%rsp
lea    0xe91(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e6d(%rip),%rbx
mov    (%rbx),%edx
lea    0x30(%rsp),%rdi
mov    $0x64,%esi
call   1060 <fgets@plt>
lea    0xe81(%rip),%rdi
call   1030 <puts@plt>
mov    (%rbx),%edx
lea    0x10(%rsp),%rdi
mov    $0x14,%esi
call   1060 <fgets@plt>
lea    0xe8c(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xedf(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1080 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x2,%eax
je     120d <main+0xad>
cmp    $0x1,%eax
jne    122c <main+0xcc>
lea    0x30(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1040 <matches@plt>
lea    0xeb4(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x30(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1070 <unmatched@plt>
lea    0xebd(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xede(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [20 x i8] c"\0ASay something nice\00"
@stdin = global i32 0
@.str.1 = [40 x i8] c"\0ANow.. What do you want to search from?\00"
@.str.2 = [56 x i8] c"\0ADo you want to count the chars that are repeated - [1]\00"
@.str.3 = [40 x i8] c"\09or the ones that do not repeat - [2] ?\00"
@.str.4 = [25 x i8] c"Your option [1] / [2] : \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [40 x i8] c"\0ACool! So there are %d chars repeated!\0A\00"
@.str.7 = [49 x i8] c"\0ACool! So there are %d chars that don't repeat!\0A\00"
@.str.8 = [32 x i8] c"\0A1 or 2.\0A\09Tough choice huh? :-|\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [20 x i8]
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @puts(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %6, i32 100, i32 %7)
%9 = call i32 @puts(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %10, i32 20, i32 %11)
%13 = call i32 @puts(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @puts(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %4)
%17 = load i32, i32* %4
switch i32 %17, label %28 [
i32 1, label %18
i32 2, label %23
]
18: ; preds = %0
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%20 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%21 = call i32 @matches(i8* %19, i8* %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %0, %18
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%25 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%26 = call i32 @unmatched(i8* %24, i8* %25)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.7, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %0, %23
%29 = call i32 @puts(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0))
br label %30
30: ; preds = %28
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"\0ASay something nice\00"
@stdin = global i32 0
@.str.1 = [40 x i8] c"\0ANow.. What do you want to search from?\00"
@.str.2 = [56 x i8] c"\0ADo you want to count the chars that are repeated - [1]\00"
@.str.3 = [40 x i8] c"\09or the ones that do not repeat - [2] ?\00"
@.str.4 = [25 x i8] c"Your option [1] / [2] : \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [40 x i8] c"\0ACool! So there are %d chars repeated!\0A\00"
@.str.7 = [49 x i8] c"\0ACool! So there are %d chars that don't repeat!\0A\00"
@.str.8 = [32 x i8] c"\0A1 or 2.\0A\09Tough choice huh? :-|\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [20 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %4, i32 100, i32 %8)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %5, i32 20, i32 %11)
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %3)
%17 = load i32, i32* %3
switch i32 %17, label %24 [
i32 1, label %18
i32 2, label %21
]
18: ; preds = %0
%19 = call i32 @matches(i8* %4, i8* %5)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %0, %18
%22 = call i32 @unmatched(i8* %4, i8* %5)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.7, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %0, %21
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0))
ret i32 0
}