#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int strlen(char *);
int main(int argc, char **argv) {
  FILE *f1, *f2;
  char *f2n;
  int n, c, offset;
  if (argc < 2)
    return 1;
  for (n = 1; n < argc; n++) {
    f2n = (char *)malloc((strlen(argv[n]) + 4) * sizeof(char));
    if (f2n == NULL)
      return 1;
    sprintf(f2n, "%s.up", argv[n]);
    f1 = fopen(argv[n], "r");
    f2 = fopen(f2n, "w");
    free(f2n);
    if (f1 == NULL || f2 == NULL)
      return 1;
    while ((c = fgetc(f1)) != EOF) {
      offset = (c >= 'a' && c <= 'z') ? 'Z' - 'z' : 0;
      fputc(c + offset, f2);
    }
    fclose(f1);
    fclose(f2);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11ac <main+0x2c>
movl   $0x1,-0x4(%rbp)
jmp    12f9 <main+0x179>
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12f2 <main+0x172>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <strlen@plt>
add    $0x4,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11fb <main+0x7b>
movl   $0x1,-0x4(%rbp)
jmp    12f9 <main+0x179>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xdee(%rip),%rsi
call   10a0 <sprintf@plt>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xddc(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xdca(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x18(%rbp)
je     1266 <main+0xe6>
cmpq   $0x0,-0x20(%rbp)
jne    1272 <main+0xf2>
movl   $0x1,-0x4(%rbp)
jmp    12f9 <main+0x179>
jmp    1277 <main+0xf7>
mov    -0x18(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,-0x30(%rbp)
mov    0x2d5e(%rip),%rcx
cmp    (%rcx),%eax
je     12d2 <main+0x152>
xor    %eax,%eax
cmpl   $0x61,-0x30(%rbp)
mov    %al,-0x35(%rbp)
jl     12ab <main+0x12b>
cmpl   $0x7a,-0x30(%rbp)
setle  %al
mov    %al,-0x35(%rbp)
mov    -0x35(%rbp),%dl
xor    %eax,%eax
mov    $0xffffffe0,%ecx
test   $0x1,%dl
cmovne %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%edi
add    -0x34(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1070 <fputc@plt>
jmp    1277 <main+0xf7>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11b3 <main+0x33>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x1,%eax
cmp    $0x2,%edi
jl     1289 <main+0x109>
mov    %rsi,%rbx
mov    %edi,%eax
mov    %rax,(%rsp)
mov    $0x1,%r13d
mov    0x2e39(%rip),%r12
jmp    11de <main+0x5e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
add    $0x1,%r13
cmp    (%rsp),%r13
je     1287 <main+0x107>
mov    (%rbx,%r13,8),%rdi
call   1050 <strlen@plt>
lea    0x4(%rax),%edi
call   1080 <malloc@plt>
test   %rax,%rax
je     1280 <main+0x100>
mov    %rax,%r15
mov    (%rbx,%r13,8),%rdx
mov    %rax,%rdi
lea    0xdf7(%rip),%rsi
call   10a0 <sprintf@plt>
mov    (%rbx,%r13,8),%rdi
lea    0xded(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbp
mov    %r15,%rdi
lea    0xddd(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r14
mov    %r15,%rdi
call   1030 <free@plt>
test   %rbp,%rbp
je     1280 <main+0x100>
test   %r14,%r14
je     1280 <main+0x100>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbp,%rdi
call   1060 <fgetc@plt>
cmp    (%r12),%eax
je     11c0 <main+0x40>
lea    -0x61(%rax),%ecx
xor    %edx,%edx
cmp    $0x1a,%ecx
setae  %dl
shl    $0x5,%edx
lea    (%rdx,%rax,1),%edi
add    $0xffffffe0,%edi
mov    %r14,%rsi
call   1070 <fputc@plt>
jmp    1250 <main+0xd0>
mov    $0x1,%eax
jmp    1289 <main+0x109>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s.up\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@EOF = global i32 0
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 i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 2
br i1 %13, label %14, label %15
14: ; preds = %2
store i32 1, i32* %3
br label %90
15: ; preds = %2
store i32 1, i32* %9
br label %16
16: ; preds = %86, %15
%17 = load i32, i32* %9
%18 = load i32, i32* %4
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %89
20: ; preds = %16
%21 = load i8**, i8*** %5
%22 = load i32, i32* %9
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
%25 = load i8*, i8** %24
%26 = call i32 @strlen(i8* %25)
%27 = add nsw i32 %26, 4
%28 = sext i32 %27 to i64
%29 = mul i64 %28, 1
%30 = trunc i64 %29 to i32
%31 = call i64 @malloc(i32 %30)
%32 = inttoptr i64 %31 to i8*
store i8* %32, i8** %8
%33 = load i8*, i8** %8
%34 = icmp eq i8* %33, null
br i1 %34, label %35, label %36
35: ; preds = %20
store i32 1, i32* %3
br label %90
36: ; preds = %20
%37 = load i8*, i8** %8
%38 = load i8**, i8*** %5
%39 = load i32, i32* %9
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8*, i8** %38, i64 %40
%42 = load i8*, i8** %41
%43 = call i32 @sprintf(i8* %37, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %42)
%44 = load i8**, i8*** %5
%45 = load i32, i32* %9
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8*, i8** %44, i64 %46
%48 = load i8*, i8** %47
%49 = call i32* @fopen(i8* %48, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %49, i32** %6
%50 = load i8*, i8** %8
%51 = call i32* @fopen(i8* %50, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %51, i32** %7
%52 = load i8*, i8** %8
%53 = call i32 @free(i8* %52)
%54 = load i32*, i32** %6
%55 = icmp eq i32* %54, null
br i1 %55, label %59, label %56
56: ; preds = %36
%57 = load i32*, i32** %7
%58 = icmp eq i32* %57, null
br i1 %58, label %59, label %60
59: ; preds = %56, %36
store i32 1, i32* %3
br label %90
60: ; preds = %56
br label %61
61: ; preds = %72, %60
%62 = load i32*, i32** %6
%63 = call i32 @fgetc(i32* %62)
store i32 %63, i32* %10
%64 = load i32, i32* @EOF
%65 = icmp ne i32 %63, %64
br i1 %65, label %66, label %81
66: ; preds = %61
%67 = load i32, i32* %10
%68 = icmp sge i32 %67, 97
br i1 %68, label %69, label %72
69: ; preds = %66
%70 = load i32, i32* %10
%71 = icmp sle i32 %70, 122
br label %72
72: ; preds = %69, %66
%73 = phi i1 [ false, %66 ], [ %71, %69 ]
%74 = zext i1 %73 to i64
%75 = select i1 %73, i32 -32, i32 0
store i32 %75, i32* %11
%76 = load i32, i32* %10
%77 = load i32, i32* %11
%78 = add nsw i32 %76, %77
%79 = load i32*, i32** %7
%80 = call i32 @fputc(i32 %78, i32* %79)
br label %61
81: ; preds = %61
%82 = load i32*, i32** %6
%83 = call i32 @fclose(i32* %82)
%84 = load i32*, i32** %7
%85 = call i32 @fclose(i32* %84)
br label %86
86: ; preds = %81
%87 = load i32, i32* %9
%88 = add nsw i32 %87, 1
store i32 %88, i32* %9
br label %16
89: ; preds = %16
store i32 0, i32* %3
br label %90
90: ; preds = %89, %59, %35, %14
%91 = load i32, i32* %3
ret i32 %91
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s.up\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@EOF = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %44, label %4
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %39
%7 = phi i64 [ 1, %4 ], [ %42, %39 ]
%8 = getelementptr inbounds i8*, i8** %1, i64 %7
%9 = load i8*, i8** %8
%10 = tail call i32 @strlen(i8* %9)
%11 = add nsw i32 %10, 4
%12 = tail call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to i8*
%14 = icmp eq i64 %12, 0
br i1 %14, label %44, label %15
15: ; preds = %6
%16 = load i8*, i8** %8
%17 = tail call i32 @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = load i8*, i8** %8
%19 = tail call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%20 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%21 = tail call i32 @free(i8* %13)
%22 = icmp eq i32* %19, null
%23 = icmp eq i32* %20, null
%24 = or i1 %22, %23
br i1 %24, label %44, label %25
25: ; preds = %15
%26 = tail call i32 @fgetc(i32* %19)
%27 = load i32, i32* @EOF
%28 = icmp eq i32 %26, %27
br i1 %28, label %39, label %29
29: ; preds = %25, %29
%30 = phi i32 [ %36, %29 ], [ %26, %25 ]
%31 = add i32 %30, -97
%32 = icmp ult i32 %31, 26
%33 = select i1 %32, i32 -32, i32 0
%34 = add nsw i32 %33, %30
%35 = tail call i32 @fputc(i32 %34, i32* %20)
%36 = tail call i32 @fgetc(i32* %19)
%37 = load i32, i32* @EOF
%38 = icmp eq i32 %36, %37
br i1 %38, label %39, label %29
39: ; preds = %29, %25
%40 = tail call i32 @fclose(i32* %19)
%41 = tail call i32 @fclose(i32* %20)
%42 = add nuw nsw i64 %7, 1
%43 = icmp eq i64 %42, %5
br i1 %43, label %44, label %6
44: ; preds = %6, %15, %39, %2
%45 = phi i32 [ 1, %2 ], [ 1, %6 ], [ 1, %15 ], [ 0, %39 ]
ret i32 %45
}