#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 EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
int main(int argc, char **argv) {
  printf("= Aufgabe 19 =\n");
  if (argc > 1) {
    for (int i = 0; i < strlen(argv[1]); i++) {
      switch (argv[1][i]) {
      case 'w':
        argv[1][i] = 'x';
        break;
      case 'x':
        argv[1][i] = 'w';
        break;
      default:
        continue;
        break;
      }
    }
    printf("%s\n", argv[1]);
  } else {
    printf("Error: keine Parameter\n");
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x1,-0x8(%rbp)
jle    1204 <main+0xe4>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    11e9 <main+0xc9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x77,%eax
je     11a7 <main+0x87>
jmp    1196 <main+0x76>
mov    -0x1c(%rbp),%eax
sub    $0x78,%eax
je     11bc <main+0x9c>
jmp    11d1 <main+0xb1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x14(%rbp),%rcx
movb   $0x78,(%rax,%rcx,1)
jmp    11d6 <main+0xb6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x14(%rbp),%rcx
movb   $0x77,(%rax,%rcx,1)
jmp    11d6 <main+0xb6>
jmp    11db <main+0xbb>
jmp    11db <main+0xbb>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1155 <main+0x35>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1212 <main+0xf2>
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2dc7(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xed1(%rip),%rdi
call   1030 <puts@plt>
cmp    $0x2,%ebp
jl     117f <main+0x5f>
mov    0x8(%rbx),%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1188 <main+0x68>
xor    %ebp,%ebp
jmp    1169 <main+0x49>
nopw   0x0(%rax,%rax,1)
mov    $0x78,%cl
mov    %cl,(%rax,%rbp,1)
add    $0x1,%rbp
mov    0x8(%rbx),%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbp
jge    1188 <main+0x68>
mov    0x8(%rbx),%rax
movsbl (%rax,%rbp,1),%ecx
cmp    $0x77,%ecx
je     1150 <main+0x30>
cmp    $0x78,%ecx
jne    1155 <main+0x35>
mov    $0x77,%cl
jmp    1152 <main+0x32>
lea    0xe89(%rip),%rdi
jmp    118c <main+0x6c>
mov    0x8(%rbx),%rdi
call   1030 <puts@plt>
mov    0x2e48(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@str = [15 x i8] c"= Aufgabe 19 =\00"
@str.3 = [23 x i8] c"Error: keine Parameter\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%4 = icmp sgt i32 %0, 1
br i1 %4, label %5, label %27
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32 @strlen(i8* %7)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %21, %5
%11 = load i8*, i8** %6
br label %27
12: ; preds = %5, %21
%13 = phi i64 [ %22, %21 ], [ 0, %5 ]
%14 = load i8*, i8** %6
%15 = getelementptr inbounds i8, i8* %14, i64 %13
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
switch i32 %17, label %21 [
i32 119, label %19
i32 120, label %18
]
18: ; preds = %12
br label %19
19: ; preds = %12, %18
%20 = phi i8 [ 119, %18 ], [ 120, %12 ]
store i8 %20, i8* %15
br label %21
21: ; preds = %19, %12
%22 = add nuw nsw i64 %13, 1
%23 = load i8*, i8** %6
%24 = tail call i32 @strlen(i8* %23)
%25 = sext i32 %24 to i64
%26 = icmp slt i64 %22, %25
br i1 %26, label %12, label %10
27: ; preds = %2, %10
%28 = phi i8* [ %11, %10 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.3, i64 0, i64 0), %2 ]
%29 = tail call i32 @puts(i8* dereferenceable(1) %28)
%30 = load i32, i32* @EXIT_SUCCESS
ret i32 %30
}