#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 mystrlen(char *);
char *mystrrevcopy(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  char buf[10];
  if (argc != 3) {
    printf("Nebyly zadany 2 retezce!\n");
    return 1;
  }
  printf("Delka prvniho retezce (tj. %s): %u\n", argv[1], mystrlen(argv[1]));
  printf("Delka druheho retezce (tj. %s): %u\n", argv[2], mystrlen(argv[2]));
  if ((mystrlen(argv[1]) + mystrlen(argv[2])) > 10) {
    printf("Nedostatecna velikost pole!\n");
    return 2;
  }
  char *ptr = mystrrevcopy(argv[1], buf);
  mystrrevcopy(argv[2], ptr);
  printf("Vysledek revezovani a spojeni: %s\n", buf);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     116a <main+0x3a>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1243 <main+0x113>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <mystrlen@plt>
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <mystrlen@plt>
mov    -0x38(%rbp),%rsi
mov    %eax,%edx
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <mystrlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <mystrlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
cmp    $0xa,%eax
jle    120b <main+0xdb>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1243 <main+0x113>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x1a(%rbp),%rsi
call   1050 <mystrrevcopy@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <mystrrevcopy@plt>
lea    -0x1a(%rbp),%rsi
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
cmp    $0x3,%edi
jne    11c0 <main+0x80>
mov    %rsi,%rbx
mov    0x8(%rsi),%rbp
mov    %rbp,%rdi
call   1050 <mystrlen@plt>
lea    0xe9d(%rip),%rdi
xor    %r14d,%r14d
mov    %rbp,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rbx),%rbp
mov    %rbp,%rdi
call   1050 <mystrlen@plt>
lea    0xe9f(%rip),%rdi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rbx),%rdi
call   1050 <mystrlen@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
call   1050 <mystrlen@plt>
add    %ebp,%eax
cmp    $0xb,%eax
jl     11d4 <main+0x94>
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%r14d
jmp    1202 <main+0xc2>
lea    0xec0(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%r14d
jmp    1202 <main+0xc2>
mov    0x8(%rbx),%rdi
lea    0x6(%rsp),%rbp
mov    %rbp,%rsi
call   1060 <mystrrevcopy@plt>
mov    0x10(%rbx),%rdi
mov    %rax,%rsi
call   1060 <mystrrevcopy@plt>
lea    0xe50(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Nebyly zadany 2 retezce!\0A\00"
@.str.1 = [36 x i8] c"Delka prvniho retezce (tj. %s): %u\0A\00"
@.str.2 = [36 x i8] c"Delka druheho retezce (tj. %s): %u\0A\00"
@.str.3 = [29 x i8] c"Nedostatecna velikost pole!\0A\00"
@.str.4 = [35 x i8] c"Vysledek revezovani a spojeni: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [10 x i8]
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 3
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %54
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @mystrlen(i8* %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %15, i32 %19)
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i32 @mystrlen(i8* %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* %23, i32 %27)
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32 @mystrlen(i8* %31)
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = call i32 @mystrlen(i8* %35)
%37 = add nsw i32 %32, %36
%38 = icmp sgt i32 %37, 10
br i1 %38, label %39, label %41
39: ; preds = %12
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
store i32 2, i32* %3
br label %54
41: ; preds = %12
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 1
%44 = load i8*, i8** %43
%45 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%46 = call i8* @mystrrevcopy(i8* %44, i8* %45)
store i8* %46, i8** %7
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 2
%49 = load i8*, i8** %48
%50 = load i8*, i8** %7
%51 = call i8* @mystrrevcopy(i8* %49, i8* %50)
%52 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i8* %52)
br label %54
54: ; preds = %41, %39, %10
%55 = load i32, i32* %3
ret i32 %55
}

LLVM IR (-O2):
@.str.1 = [36 x i8] c"Delka prvniho retezce (tj. %s): %u\0A\00"
@.str.2 = [36 x i8] c"Delka druheho retezce (tj. %s): %u\0A\00"
@.str.4 = [35 x i8] c"Vysledek revezovani a spojeni: %s\0A\00"
@str = [28 x i8] c"Nedostatecna velikost pole!\00"
@str.5 = [25 x i8] c"Nebyly zadany 2 retezce!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [10 x i8]
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 3
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.5, i64 0, i64 0))
br label %31
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @mystrlen(i8* %10)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %10, i32 %11)
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i32 @mystrlen(i8* %14)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* %14, i32 %15)
%17 = load i8*, i8** %9
%18 = tail call i32 @mystrlen(i8* %17)
%19 = load i8*, i8** %13
%20 = tail call i32 @mystrlen(i8* %19)
%21 = add nsw i32 %20, %18
%22 = icmp sgt i32 %21, 10
br i1 %22, label %23, label %25
23: ; preds = %8
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br label %31
25: ; preds = %8
%26 = load i8*, i8** %9
%27 = call i8* @mystrrevcopy(i8* %26, i8* %4)
%28 = load i8*, i8** %13
%29 = call i8* @mystrrevcopy(i8* %28, i8* %27)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i8* %4)
br label %31
31: ; preds = %25, %23, %6
%32 = phi i32 [ 1, %6 ], [ 2, %23 ], [ 0, %25 ]
ret i32 %32
}