#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 */
char *dup(char *, int *);
int /*<<< orphan*/ exit(int);
int *genccountdict(char *);
char *nnodup(char *, int *);
char *nodup(char *, int *);
int /*<<< orphan*/ printf(char *, char *);
int strlen(char *);
char toupper(char);
int main(int argc, char **argv) {
  int i;
  if (argc != 2)
    exit(1);
  char *string = *(argv + 1);
  int *dict = genccountdict(string);
  for (i = 0; i < strlen(string); i++)
    string[i] = toupper(string[i]);
  printf("nodup: %s\n", nodup(string, dict));
  printf("nnodup: %s\n", nnodup(string, dict));
  printf("dup: %s\n", dup(string, dict));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11aa <main+0x2a>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   10a0 <genccountdict@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cmp    %ecx,%eax
jge    1212 <main+0x92>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <toupper@plt>
mov    %al,%dl
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ca <main+0x4a>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1070 <nodup@plt>
mov    %rax,%rsi
lea    0xdd8(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1080 <nnodup@plt>
mov    %rax,%rsi
lea    0xdbb(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <dup@plt>
mov    %rax,%rsi
lea    0xda2(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
cmp    $0x2,%edi
jne    1227 <main+0xa7>
mov    0x8(%rsi),%r15
mov    %r15,%rdi
call   10a0 <genccountdict@plt>
mov    %rax,%r14
mov    %r15,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11d1 <main+0x51>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsbl (%r15,%rbx,1),%edi
call   1030 <toupper@plt>
mov    %al,(%r15,%rbx,1)
add    $0x1,%rbx
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     11b0 <main+0x30>
mov    %r15,%rdi
mov    %r14,%rsi
call   1070 <nodup@plt>
lea    0xe1e(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1080 <nnodup@plt>
lea    0xe03(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <dup@plt>
lea    0xdec(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"nodup: %s\0A\00"
@.str.1 = [12 x i8] c"nnodup: %s\0A\00"
@.str.2 = [9 x i8] c"dup: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
store i8* %16, i8** %7
%17 = load i8*, i8** %7
%18 = call i32* @genccountdict(i8* %17)
store i32* %18, i32** %8
store i32 0, i32* %6
br label %19
19: ; preds = %35, %13
%20 = load i32, i32* %6
%21 = load i8*, i8** %7
%22 = call i32 @strlen(i8* %21)
%23 = icmp slt i32 %20, %22
br i1 %23, label %24, label %38
24: ; preds = %19
%25 = load i8*, i8** %7
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
%30 = call signext i8 @toupper(i8 signext %29)
%31 = load i8*, i8** %7
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
store i8 %30, i8* %34
br label %35
35: ; preds = %24
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 1
store i32 %37, i32* %6
br label %19
38: ; preds = %19
%39 = load i8*, i8** %7
%40 = load i32*, i32** %8
%41 = call i8* @nodup(i8* %39, i32* %40)
%42 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %41)
%43 = load i8*, i8** %7
%44 = load i32*, i32** %8
%45 = call i8* @nnodup(i8* %43, i32* %44)
%46 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %45)
%47 = load i8*, i8** %7
%48 = load i32*, i32** %8
%49 = call i8* @dup(i8* %47, i32* %48)
%50 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %49)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"nodup: %s\0A\00"
@.str.1 = [12 x i8] c"nnodup: %s\0A\00"
@.str.2 = [9 x i8] c"dup: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @exit(i32 1)
unreachable
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32* @genccountdict(i8* %8)
%10 = tail call i32 @strlen(i8* %8)
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %21
12: ; preds = %6, %12
%13 = phi i64 [ %17, %12 ], [ 0, %6 ]
%14 = getelementptr inbounds i8, i8* %8, i64 %13
%15 = load i8, i8* %14
%16 = tail call signext i8 @toupper(i8 signext %15)
store i8 %16, i8* %14
%17 = add nuw nsw i64 %13, 1
%18 = tail call i32 @strlen(i8* %8)
%19 = sext i32 %18 to i64
%20 = icmp slt i64 %17, %19
br i1 %20, label %12, label %21
21: ; preds = %12, %6
%22 = tail call i8* @nodup(i8* %8, i32* %9)
%23 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = tail call i8* @nnodup(i8* %8, i32* %9)
%25 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %24)
%26 = tail call i8* @dup(i8* %8, i32* %9)
%27 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %26)
ret i32 0
}