#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 *code(char *, int);
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ puts(char *);
int main(int argc, char **argv) {
  puts("Wpisz tekst do zakodowania:\n");
  char buff[1024];
  gets(buff);
  char *c = code(buff, 0);
  printf("Zakodowany: %s\n", c);
  c = code(c, 1);
  printf("Odkodowany: %s\n", c);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
lea    -0x410(%rbp),%rdi
call   1050 <gets@plt>
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
call   1060 <code@plt>
mov    %rax,-0x418(%rbp)
mov    -0x418(%rbp),%rsi
lea    0xe90(%rip),%rdi
call   1040 <printf@plt>
mov    -0x418(%rbp),%rdi
mov    $0x1,%esi
call   1060 <code@plt>
mov    %rax,-0x418(%rbp)
mov    -0x418(%rbp),%rsi
lea    0xe75(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x400,%rsp
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <gets@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <code@plt>
mov    %rax,%rbx
lea    0xeaa(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1060 <code@plt>
lea    0xe9e(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Wpisz tekst do zakodowania:\0A\00"
@.str.1 = [16 x i8] c"Zakodowany: %s\0A\00"
@.str.2 = [16 x i8] c"Odkodowany: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [1024 x i8]
%6 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = call i32 @puts(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%9 = call i32 @gets(i8* %8)
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%11 = call i8* @code(i8* %10, i32 0)
store i8* %11, i8** %6
%12 = load i8*, i8** %6
%13 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = load i8*, i8** %6
%15 = call i8* @code(i8* %14, i32 1)
store i8* %15, i8** %6
%16 = load i8*, i8** %6
%17 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %16)
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"Wpisz tekst do zakodowania:\0A\00"
@.str.1 = [16 x i8] c"Zakodowany: %s\0A\00"
@.str.2 = [16 x i8] c"Odkodowany: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1024 x i8]
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = call i32 @gets(i8* %5)
%7 = call i8* @code(i8* %5, i32 0)
%8 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = call i8* @code(i8* %7, i32 1)
%10 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %9)
ret i32 0
}