#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*/ __fpurge(int /*<<< orphan*/);
int /*<<< orphan*/ getline(char **, size_t *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
char rotate(char, int);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stdin;
int strlen(char *);
int main(int argc, char *argv[]) {
  int key = 0, c;
  char *message = NULL;
  size_t len = 0;
  printf("Key: ");
  scanf("%i", &key);
  __fpurge(stdin);
  printf("Message: ");
  getline(&message, &len, stdin);
  for (c = 0; c < strlen(message); c++) {
    message[c] = rotate(message[c], key);
  }
  printf("%s", message);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe64(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1070 <scanf@plt>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
call   1030 <__fpurge@plt>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edx
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1080 <getline@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cmp    %ecx,%eax
jge    1231 <main+0xd1>
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x14(%rbp),%esi
movsbl %al,%edi
call   1060 <rotate@plt>
mov    %al,%dl
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11e4 <main+0x84>
mov    -0x20(%rbp),%rsi
lea    0xdd7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movl   $0x0,0x14(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x18(%rsp)
lea    0xe7a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe72(%rip),%rdi
lea    0x14(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x2e43(%rip),%rbx
mov    (%rbx),%edi
call   1030 <__fpurge@plt>
lea    0xe56(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%edx
lea    0x8(%rsp),%rdi
lea    0x18(%rsp),%rsi
call   1080 <getline@plt>
mov    0x8(%rsp),%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    120f <main+0xaf>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rax
movsbl (%rax,%rbx,1),%edi
mov    0x14(%rsp),%esi
call   1060 <rotate@plt>
mov    0x8(%rsp),%rcx
mov    %al,(%rcx,%rbx,1)
add    $0x1,%rbx
mov    0x8(%rsp),%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     11e0 <main+0x80>
mov    0x8(%rsp),%rsi
lea    0xdf8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"Key: \00"
@.str.1 = [3 x i8] c"%i\00"
@stdin = global i32 0
@.str.2 = [10 x i8] c"Message: \00"
@.str.3 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i8* null, i8** %8
store i64 0, i64* %9
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%12 = load i32, i32* @stdin
%13 = call i32 @__fpurge(i32 %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32, i32* @stdin
%16 = call i32 @getline(i8** %8, i64* %9, i32 %15)
store i32 0, i32* %7
br label %17
17: ; preds = %34, %2
%18 = load i32, i32* %7
%19 = load i8*, i8** %8
%20 = call i32 @strlen(i8* %19)
%21 = icmp slt i32 %18, %20
br i1 %21, label %22, label %37
22: ; preds = %17
%23 = load i8*, i8** %8
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = load i32, i32* %6
%29 = call signext i8 @rotate(i8 signext %27, i32 %28)
%30 = load i8*, i8** %8
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
store i8 %29, i8* %33
br label %34
34: ; preds = %22
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %17
37: ; preds = %17
%38 = load i8*, i8** %8
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %38)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"Key: \00"
@.str.1 = [3 x i8] c"%i\00"
@stdin = global i32 0
@.str.2 = [10 x i8] c"Message: \00"
@.str.3 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%8 = bitcast i64* %5 to i8*
store i64 0, i64* %5
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%11 = load i32, i32* @stdin
%12 = call i32 @__fpurge(i32 %11)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%14 = load i32, i32* @stdin
%15 = call i32 @getline(i8** %4, i64* %5, i32 %14)
%16 = load i8*, i8** %4
%17 = call i32 @strlen(i8* %16)
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %33
19: ; preds = %2, %19
%20 = phi i64 [ %28, %19 ], [ 0, %2 ]
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i64 %20
%23 = load i8, i8* %22
%24 = load i32, i32* %3
%25 = call signext i8 @rotate(i8 signext %23, i32 %24)
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i64 %20
store i8 %25, i8* %27
%28 = add nuw nsw i64 %20, 1
%29 = load i8*, i8** %4
%30 = call i32 @strlen(i8* %29)
%31 = sext i32 %30 to i64
%32 = icmp slt i64 %28, %31
br i1 %32, label %19, label %33
33: ; preds = %19, %2
%34 = load i8*, i8** %4
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %34)
ret i32 0
}