#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*/ convert2cp(char *, char *);
int /*<<< orphan*/ convert2utf(char *, char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ puts(char *);
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  if (argc == 4) {
    if (strcmp(argv[1], "utf8") == 0)
      convert2utf(argv[2], argv[3]);
    else if (strcmp(argv[1], "cp1251") == 0)
      convert2cp(argv[2], argv[3]);
    else {
      puts("Unknown encoding!");
      exit(0);
    }
  } else {
    puts("");
    puts("Usage: cyrconv [TARGET-ENCODING] [INPUT_FILE] [OUTPUT_FILE]");
    puts("TARGET-ENCODING: utf8 or cp1251");
    puts("");
    puts("To convert from cp1251 to utf8:");
    puts("cyrconv utf8 INPUT_FILE OUTPUT_FILE");
    puts("");
    puts("To convert from utf8 to cp1251:");
    puts("cyrconv cp1251 INPUT_FILE OUTPUT_FILE");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jne    11fd <main+0xad>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe81(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11a8 <main+0x58>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1060 <convert2utf@plt>
jmp    11f8 <main+0xa8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xeb5(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11e0 <main+0x90>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1040 <convert2cp@plt>
jmp    11f3 <main+0xa3>
lea    0xe1e(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1070 <exit@plt>
jmp    11f8 <main+0xa8>
jmp    1269 <main+0x119>
lea    0xe12(%rip),%rdi
call   1030 <puts@plt>
lea    0xe07(%rip),%rdi
call   1030 <puts@plt>
lea    0xe37(%rip),%rdi
call   1030 <puts@plt>
lea    0xdee(%rip),%rdi
call   1030 <puts@plt>
lea    0xe3f(%rip),%rdi
call   1030 <puts@plt>
lea    0xe53(%rip),%rdi
call   1030 <puts@plt>
lea    0xdca(%rip),%rdi
call   1030 <puts@plt>
lea    0xe5f(%rip),%rdi
call   1030 <puts@plt>
lea    0xe73(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x4,%edi
jne    11aa <main+0x4a>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe8c(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1212 <main+0xb2>
mov    0x8(%rbx),%rdi
lea    0xedf(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    1223 <main+0xc3>
mov    0x10(%rbx),%rdi
mov    0x18(%rbx),%rsi
call   1050 <convert2cp@plt>
jmp    121f <main+0xbf>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe5c(%rip),%rdi
call   1040 <puts@plt>
lea    0xe8c(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe96(%rip),%rdi
call   1040 <puts@plt>
lea    0xeaa(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xeb8(%rip),%rdi
call   1040 <puts@plt>
lea    0xecc(%rip),%rdi
call   1040 <puts@plt>
jmp    121f <main+0xbf>
mov    0x10(%rbx),%rdi
mov    0x18(%rbx),%rsi
call   1070 <convert2utf@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xddb(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"utf8\00"
@.str.1 = [7 x i8] c"cp1251\00"
@.str.2 = [18 x i8] c"Unknown encoding!\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [60 x i8] c"Usage: cyrconv [TARGET-ENCODING] [INPUT_FILE] [OUTPUT_FILE]\00"
@.str.5 = [32 x i8] c"TARGET-ENCODING: utf8 or cp1251\00"
@.str.6 = [32 x i8] c"To convert from cp1251 to utf8:\00"
@.str.7 = [36 x i8] c"cyrconv utf8 INPUT_FILE OUTPUT_FILE\00"
@.str.8 = [32 x i8] c"To convert from utf8 to cp1251:\00"
@.str.9 = [38 x i8] c"cyrconv cp1251 INPUT_FILE OUTPUT_FILE\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 4
br i1 %7, label %8, label %41
8: ; preds = %2
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %8
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 2
%17 = load i8*, i8** %16
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 3
%20 = load i8*, i8** %19
%21 = call i32 @convert2utf(i8* %17, i8* %20)
br label %40
22: ; preds = %8
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %36
28: ; preds = %22
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 3
%34 = load i8*, i8** %33
%35 = call i32 @convert2cp(i8* %31, i8* %34)
br label %39
36: ; preds = %22
%37 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%38 = call i32 @exit(i32 0)
unreachable
39: ; preds = %28
br label %40
40: ; preds = %39, %14
br label %51
41: ; preds = %2
%42 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%43 = call i32 @puts(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.4, i64 0, i64 0))
%44 = call i32 @puts(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
%45 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%46 = call i32 @puts(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
%47 = call i32 @puts(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0))
%48 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%49 = call i32 @puts(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0))
%50 = call i32 @puts(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0))
br label %51
51: ; preds = %41, %40
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"utf8\00"
@.str.1 = [7 x i8] c"cp1251\00"
@.str.2 = [18 x i8] c"Unknown encoding!\00"
@.str.4 = [60 x i8] c"Usage: cyrconv [TARGET-ENCODING] [INPUT_FILE] [OUTPUT_FILE]\00"
@.str.5 = [32 x i8] c"TARGET-ENCODING: utf8 or cp1251\00"
@.str.6 = [32 x i8] c"To convert from cp1251 to utf8:\00"
@.str.7 = [36 x i8] c"cyrconv utf8 INPUT_FILE OUTPUT_FILE\00"
@.str.8 = [32 x i8] c"To convert from utf8 to cp1251:\00"
@.str.9 = [38 x i8] c"cyrconv cp1251 INPUT_FILE OUTPUT_FILE\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %4, label %28
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %4
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = getelementptr inbounds i8*, i8** %1, i64 3
%13 = load i8*, i8** %12
%14 = tail call i32 @convert2utf(i8* %11, i8* %13)
br label %38
15: ; preds = %4
%16 = load i8*, i8** %5
%17 = tail call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %15
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = getelementptr inbounds i8*, i8** %1, i64 3
%23 = load i8*, i8** %22
%24 = tail call i32 @convert2cp(i8* %21, i8* %23)
br label %38
25: ; preds = %15
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%27 = tail call i32 @exit(i32 0)
unreachable
28: ; preds = %2
%29 = tail call i32 @putchar(i32 10)
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.4, i64 0, i64 0))
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
%32 = tail call i32 @putchar(i32 10)
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
%34 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0))
%35 = tail call i32 @putchar(i32 10)
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0))
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0))
br label %38
38: ; preds = %9, %19, %28
ret i32 0
}