#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 /*<<< orphan*/ assert(int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ memcpy(char *, char const *, int);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char const *);
int system(char *);
int /*<<< orphan*/ unlink(char *);
int main(const int argc, const char **argv) {
  FILE *ofile;
  char filename[44];
  int rval;
  if (argc != 2 || strlen(argv[1]) != 87) {
    printf("mkcert needs the 87-byte string supplied by LetsEncrypt\n"
           "as a command-line argument.\n");
    return (-1);
  }
  memcpy(filename, argv[1], 44 - 1);
  filename[44 - 1] = '\0';
  ofile = fopen(filename, "wb");
  if (!ofile)
    printf("Didn't open '%s'\n", filename);
  assert(ofile);
  fprintf(ofile, "%s\n", argv[1]);
  fclose(ofile);
  printf("File '%s' created\n", filename);
  ofile = fopen("/tmp/put", "wb");
  assert(ofile);
  fprintf(ofile, "cd /home/projectp/public_html/.well-known/acme-challenge\n");
  fprintf(ofile, "put %s\n", filename);
  fprintf(ofile, "exit\n");
  fclose(ofile);
  rval = system("sftp -b /tmp/put -P 2900 projectp@projectpluto.com");
  printf("rval %d\n", rval);
  unlink(filename);
  return (rval);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    11c6 <main+0x36>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <strlen@plt>
cmp    $0x57,%eax
je     11e0 <main+0x50>
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12fb <main+0x16b>
lea    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    $0x2b,%edx
call   10a0 <memcpy@plt>
movb   $0x0,-0x25(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe50(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    122b <main+0x9b>
lea    -0x50(%rbp),%rsi
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1080 <assert@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe7d(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0x50(%rbp),%rsi
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe0d(%rip),%rdi
lea    0xdde(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1080 <assert@plt>
mov    -0x18(%rbp),%rdi
lea    0xdf2(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x50(%rbp),%rdx
lea    0xe16(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe0c(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xdfb(%rip),%rdi
call   1060 <system@plt>
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%esi
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x50(%rbp),%rdi
call   1030 <unlink@plt>
mov    -0x54(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x38,%rsp
cmp    $0x2,%edi
jne    12e3 <main+0x133>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1060 <strlen@plt>
cmp    $0x57,%eax
jne    12e3 <main+0x133>
mov    0x8(%rbx),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x2b,%edx
call   10b0 <memcpy@plt>
movb   $0x0,0x2b(%rsp)
lea    0xe0b(%rip),%rsi
mov    %r14,%rdi
call   10c0 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
jne    1216 <main+0x66>
lea    0xdf7(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
call   1090 <assert@plt>
mov    0x8(%rbx),%rdx
lea    0xe46(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
lea    0xdd3(%rip),%rdi
mov    %rsp,%r14
mov    %r14,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xdd2(%rip),%rdi
lea    0xda3(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1090 <assert@plt>
lea    0xdbd(%rip),%rdi
mov    $0x39,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10d0 <fwrite@plt>
lea    0xdde(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
lea    0xdd2(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10d0 <fwrite@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
lea    0xdb7(%rip),%rdi
call   1070 <system@plt>
mov    %eax,%ebx
lea    0xddc(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
call   1030 <unlink@plt>
jmp    12f4 <main+0x144>
lea    0xdcb(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [85 x i8] c"mkcert needs the 87-byte string supplied by LetsEncrypt\0Aas a command-line argument.\0A\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [18 x i8] c"Didn't open '%s'\0A\00"
@.str.3 = [4 x i8] c"%s\0A\00"
@.str.4 = [19 x i8] c"File '%s' created\0A\00"
@.str.5 = [9 x i8] c"/tmp/put\00"
@.str.6 = [58 x i8] c"cd /home/projectp/public_html/.well-known/acme-challenge\0A\00"
@.str.7 = [8 x i8] c"put %s\0A\00"
@.str.8 = [6 x i8] c"exit\0A\00"
@.str.9 = [51 x i8] c"sftp -b /tmp/put -P 2900 projectp@projectpluto.com\00"
@.str.10 = [9 x i8] c"rval %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [44 x i8]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %17, label %11
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @strlen(i8* %14)
%16 = icmp ne i32 %15, 87
br i1 %16, label %17, label %19
17: ; preds = %11, %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([85 x i8], [85 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %63
19: ; preds = %11
%20 = getelementptr inbounds [44 x i8], [44 x i8]* %7, i64 0, i64 0
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @memcpy(i8* %20, i8* %23, i32 43)
%25 = getelementptr inbounds [44 x i8], [44 x i8]* %7, i64 0, i64 43
store i8 0, i8* %25
%26 = getelementptr inbounds [44 x i8], [44 x i8]* %7, i64 0, i64 0
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %27, i32** %6
%28 = load i32*, i32** %6
%29 = icmp ne i32* %28, null
br i1 %29, label %33, label %30
30: ; preds = %19
%31 = getelementptr inbounds [44 x i8], [44 x i8]* %7, i64 0, i64 0
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %31)
br label %33
33: ; preds = %30, %19
%34 = load i32*, i32** %6
%35 = call i32 @assert(i32* %34)
%36 = load i32*, i32** %6
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 1
%39 = load i8*, i8** %38
%40 = call i32 (i32*, i8*, ...) @fprintf(i32* %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %39)
%41 = load i32*, i32** %6
%42 = call i32 @fclose(i32* %41)
%43 = getelementptr inbounds [44 x i8], [44 x i8]* %7, i64 0, i64 0
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %43)
%45 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %45, i32** %6
%46 = load i32*, i32** %6
%47 = call i32 @assert(i32* %46)
%48 = load i32*, i32** %6
%49 = call i32 (i32*, i8*, ...) @fprintf(i32* %48, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.6, i64 0, i64 0))
%50 = load i32*, i32** %6
%51 = getelementptr inbounds [44 x i8], [44 x i8]* %7, i64 0, i64 0
%52 = call i32 (i32*, i8*, ...) @fprintf(i32* %50, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i8* %51)
%53 = load i32*, i32** %6
%54 = call i32 (i32*, i8*, ...) @fprintf(i32* %53, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%55 = load i32*, i32** %6
%56 = call i32 @fclose(i32* %55)
%57 = call i32 @system(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.9, i64 0, i64 0))
store i32 %57, i32* %8
%58 = load i32, i32* %8
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i32 %58)
%60 = getelementptr inbounds [44 x i8], [44 x i8]* %7, i64 0, i64 0
%61 = call i32 @unlink(i8* %60)
%62 = load i32, i32* %8
store i32 %62, i32* %3
br label %63
63: ; preds = %33, %17
%64 = load i32, i32* %3
ret i32 %64
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [18 x i8] c"Didn't open '%s'\0A\00"
@.str.3 = [4 x i8] c"%s\0A\00"
@.str.4 = [19 x i8] c"File '%s' created\0A\00"
@.str.5 = [9 x i8] c"/tmp/put\00"
@.str.6 = [58 x i8] c"cd /home/projectp/public_html/.well-known/acme-challenge\0A\00"
@.str.7 = [8 x i8] c"put %s\0A\00"
@.str.8 = [6 x i8] c"exit\0A\00"
@.str.9 = [51 x i8] c"sftp -b /tmp/put -P 2900 projectp@projectpluto.com\00"
@.str.10 = [9 x i8] c"rval %d\0A\00"
@str = [84 x i8] c"mkcert needs the 87-byte string supplied by LetsEncrypt\0Aas a command-line argument.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [44 x i8]
%4 = getelementptr inbounds [44 x i8], [44 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 2
br i1 %5, label %6, label %11
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @strlen(i8* %8)
%10 = icmp eq i32 %9, 87
br i1 %10, label %13, label %11
11: ; preds = %6, %2
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([84 x i8], [84 x i8]* @str, i64 0, i64 0))
br label %36
13: ; preds = %6
%14 = load i8*, i8** %7
%15 = call i32 @memcpy(i8* %4, i8* %14, i32 43)
%16 = getelementptr inbounds [44 x i8], [44 x i8]* %3, i64 0, i64 43
store i8 0, i8* %16
%17 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %21
19: ; preds = %13
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %4)
br label %21
21: ; preds = %19, %13
%22 = call i32 @assert(i32* %17)
%23 = load i8*, i8** %7
%24 = call i32 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %23)
%25 = call i32 @fclose(i32* %17)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%27 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%28 = call i32 @assert(i32* %27)
%29 = call i64 @fwrite(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.6, i64 0, i64 0), i64 57, i64 1, i32* %27)
%30 = call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i8* %4)
%31 = call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i64 5, i64 1, i32* %27)
%32 = call i32 @fclose(i32* %27)
%33 = call i32 @system(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.9, i64 0, i64 0))
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i32 %33)
%35 = call i32 @unlink(i8* %4)
br label %36
36: ; preds = %21, %11
%37 = phi i32 [ -1, %11 ], [ %33, %21 ]
ret i32 %37
}