#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*/ printf(char *, ...);
int strlen(char *);
long strtol(char *, int /*<<< orphan*/ *, int);
int main(int argc, char **argv) {
  long k = strtol(argv[2], NULL, 10);
  char *s = argv[1];
  printf("Plaintext is %s\n", s);
  printf("Caesar key is %li\n", k);
  int l = strlen(s);
  for (int c = 0; c < l; c++) {
    if (s[c] >= 97) {
      s[c] = (s[c] + k - 'a') % 26 + 'a';
    } else {
      s[c] = (s[c] + k - 'A') % 26 + 'A';
    }
  }
  printf("Encyphered text is %s\n", s);
  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)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1238 <main+0x108>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x61,%eax
jl     11f7 <main+0xc7>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsbq (%rax,%rcx,1),%rax
add    -0x18(%rbp),%rax
sub    $0x61,%rax
mov    $0x1a,%ecx
cqto
idiv   %rcx
add    $0x61,%rdx
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    1225 <main+0xf5>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsbq (%rax,%rcx,1),%rax
add    -0x18(%rbp),%rax
sub    $0x41,%rax
mov    $0x1a,%ecx
cqto
idiv   %rcx
add    $0x41,%rdx
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    122a <main+0xfa>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11a3 <main+0x73>
mov    -0x20(%rbp),%rsi
lea    0xde1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    0x10(%rsi),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %rax,%r14
mov    0x8(%rbx),%r15
lea    0xeaa(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeaa(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11eb <main+0xbb>
lea    -0x41(%r14),%r8
add    $0xffffffffffffff9f,%r14
mov    %eax,%edi
xor    %esi,%esi
movabs $0x4ec4ec4ec4ec4ec5,%r9
ec c4 4e
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbq (%r15,%rsi,1),%rax
movzbl %al,%edx
add    %r14,%rdx
lea    (%r8,%rax,1),%rcx
cmp    $0x61,%rax
cmovge %rdx,%rcx
setge  %bl
shl    $0x5,%bl
mov    %rcx,%rax
imul   %r9
mov    %rdx,%rax
shr    $0x3f,%rax
shr    $0x3,%edx
add    %eax,%edx
lea    (%rdx,%rdx,4),%eax
lea    (%rax,%rax,4),%eax
add    %edx,%eax
sub    %eax,%ecx
add    %bl,%cl
add    $0x41,%cl
mov    %cl,(%r15,%rsi,1)
add    $0x1,%rsi
cmp    %rsi,%rdi
jne    11a0 <main+0x70>
lea    0xe32(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Plaintext is %s\0A\00"
@.str.1 = [19 x i8] c"Caesar key is %li\0A\00"
@.str.2 = [23 x i8] c"Encyphered text is %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 2
%12 = load i8*, i8** %11
%13 = call i64 @strtol(i8* %12, i32* null, i32 10)
store i64 %13, i64* %6
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
store i8* %16, i8** %7
%17 = load i8*, i8** %7
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load i64, i64* %6
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i64 %19)
%21 = load i8*, i8** %7
%22 = call i32 @strlen(i8* %21)
store i32 %22, i32* %8
store i32 0, i32* %9
br label %23
23: ; preds = %70, %2
%24 = load i32, i32* %9
%25 = load i32, i32* %8
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %73
27: ; preds = %23
%28 = load i8*, i8** %7
%29 = load i32, i32* %9
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp sge i32 %33, 97
br i1 %34, label %35, label %52
35: ; preds = %27
%36 = load i8*, i8** %7
%37 = load i32, i32* %9
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i64
%42 = load i64, i64* %6
%43 = add nsw i64 %41, %42
%44 = sub nsw i64 %43, 97
%45 = srem i64 %44, 26
%46 = add nsw i64 %45, 97
%47 = trunc i64 %46 to i8
%48 = load i8*, i8** %7
%49 = load i32, i32* %9
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
store i8 %47, i8* %51
br label %69
52: ; preds = %27
%53 = load i8*, i8** %7
%54 = load i32, i32* %9
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %53, i64 %55
%57 = load i8, i8* %56
%58 = sext i8 %57 to i64
%59 = load i64, i64* %6
%60 = add nsw i64 %58, %59
%61 = sub nsw i64 %60, 65
%62 = srem i64 %61, 26
%63 = add nsw i64 %62, 65
%64 = trunc i64 %63 to i8
%65 = load i8*, i8** %7
%66 = load i32, i32* %9
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i8, i8* %65, i64 %67
store i8 %64, i8* %68
br label %69
69: ; preds = %52, %35
br label %70
70: ; preds = %69
%71 = load i32, i32* %9
%72 = add nsw i32 %71, 1
store i32 %72, i32* %9
br label %23
73: ; preds = %23
%74 = load i8*, i8** %7
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %74)
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"Plaintext is %s\0A\00"
@.str.1 = [19 x i8] c"Caesar key is %li\0A\00"
@.str.2 = [23 x i8] c"Encyphered text is %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 2
%4 = load i8*, i8** %3
%5 = tail call i64 @strtol(i8* nocapture %4, i32* null, i32 10)
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i64 %5)
%10 = tail call i32 @strlen(i8* %7)
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = add i64 %5, -65
%14 = add i64 %5, -97
%15 = zext i32 %10 to i64
br label %18
16: ; preds = %18, %2
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %7)
ret i32 0
18: ; preds = %12, %18
%19 = phi i64 [ 0, %12 ], [ %32, %18 ]
%20 = getelementptr inbounds i8, i8* %7, i64 %19
%21 = load i8, i8* %20
%22 = icmp sgt i8 %21, 96
%23 = zext i8 %21 to i64
%24 = add i64 %14, %23
%25 = sext i8 %21 to i64
%26 = add i64 %13, %25
%27 = select i1 %22, i64 %24, i64 %26
%28 = select i1 %22, i8 97, i8 65
%29 = srem i64 %27, 26
%30 = trunc i64 %29 to i8
%31 = add nsw i8 %28, %30
store i8 %31, i8* %20
%32 = add nuw nsw i64 %19, 1
%33 = icmp eq i64 %32, %15
br i1 %33, label %16, label %18
}