#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 *caesar(char *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
scalar_t__ strncmp(char *, char *, int);
int main(void) {
  char *str = malloc(255);
  char *outString = NULL;
  bool running = true;
  printf(
      "Mata in text att kryptera avsluta med att skriva quit på en egen rad\n");
  while (running) {
    fgets(str, 255, stdin);
    if (strncmp(str, "quit", 4) == 0) {
      free(outString);
      free(str);
      exit(0);
    }
    outString = caesar(str, 1);
    printf("%s\n", outString);
  }
  free(str);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xff,%edi
call   1080 <malloc@plt>
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x0,-0x1c(%rbp)
je     122c <main+0xbc>
mov    -0x10(%rbp),%rdi
mov    0x2e29(%rip),%rax
mov    (%rax),%edx
mov    $0xff,%esi
call   1070 <fgets@plt>
mov    -0x10(%rbp),%rdi
lea    0xe71(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1203 <main+0x93>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1060 <caesar@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11aa <main+0x3a>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0xff,%edi
call   1080 <malloc@plt>
mov    %rax,%r14
lea    0xe79(%rip),%rdi
call   1050 <puts@plt>
mov    0x2e50(%rip),%r12
mov    (%r12),%edx
mov    %r14,%rdi
mov    $0xff,%esi
call   1070 <fgets@plt>
lea    0xe50(%rip),%rsi
mov    %r14,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    11c6 <main+0x56>
xor    %ebx,%ebx
jmp    120e <main+0x9e>
lea    0xe33(%rip),%r15
nopl   (%rax)
mov    %r14,%rdi
mov    $0x1,%esi
call   1060 <caesar@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <puts@plt>
mov    (%r12),%edx
mov    %r14,%rdi
mov    $0xff,%esi
call   1070 <fgets@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    11d0 <main+0x60>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [71 x i8] c"Mata in text att kryptera avsluta med att skriva quit p\C3\A5 en egen rad\0A\00"
@stdin = global i32 0
@.str.1 = [5 x i8] c"quit\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i32 0, i32* %1
%5 = call i8* @malloc(i32 255)
store i8* %5, i8** %2
store i8* null, i8** %3
store i32 1, i32* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %23, %0
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %28
10: ; preds = %7
%11 = load i8*, i8** %2
%12 = load i32, i32* @stdin
%13 = call i32 @fgets(i8* %11, i32 255, i32 %12)
%14 = load i8*, i8** %2
%15 = call i64 @strncmp(i8* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %23
17: ; preds = %10
%18 = load i8*, i8** %3
%19 = call i32 @free(i8* %18)
%20 = load i8*, i8** %2
%21 = call i32 @free(i8* %20)
%22 = call i32 @exit(i32 0)
unreachable
23: ; preds = %10
%24 = load i8*, i8** %2
%25 = call i8* @caesar(i8* %24, i32 1)
store i8* %25, i8** %3
%26 = load i8*, i8** %3
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %26)
br label %7
28: ; preds = %7
%29 = load i8*, i8** %2
%30 = call i32 @free(i8* %29)
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str.1 = [5 x i8] c"quit\00"
@str = [70 x i8] c"Mata in text att kryptera avsluta med att skriva quit p\C3\A5 en egen rad\00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(255) i8* @malloc(i32 255)
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @str, i64 0, i64 0))
%3 = load i32, i32* @stdin
%4 = tail call i32 @fgets(i8* %1, i32 255, i32 %3)
%5 = tail call i64 @strncmp(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %12, %0
%8 = phi i8* [ null, %0 ], [ %13, %12 ]
%9 = tail call i32 @free(i8* %8)
%10 = tail call i32 @free(i8* %1)
%11 = tail call i32 @exit(i32 0)
unreachable
12: ; preds = %0, %12
%13 = tail call i8* @caesar(i8* %1, i32 1)
%14 = tail call i32 @puts(i8* dereferenceable(1) %13)
%15 = load i32, i32* @stdin
%16 = tail call i32 @fgets(i8* %1, i32 255, i32 %15)
%17 = tail call i64 @strncmp(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%18 = icmp eq i64 %17, 0
br i1 %18, label %7, label %12
}