#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*/ buf_tpl;
typedef int /*<<< orphan*/ buf_post;
typedef int /*<<< orphan*/ buf_auth;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
char *getenv(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ req_build_auth(char *, int, char *, char *);
int /*<<< orphan*/ req_build_post(char *, int, char *, char *, char *);
int /*<<< orphan*/ req_send(char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ tpl_build_rand(char *, int);
int main(int argc, char *argv[]) {
  if (argc != 3) {
    fprintf(stderr, "usage: %s <stream> <subject>\n", argv[0]);
    exit(1);
  }
  char *api_email = getenv("CRONMOJI_EMAIL");
  if (!api_email) {
    fprintf(stderr, "couldn't get e-mail from %s\n", "CRONMOJI_EMAIL");
    exit(1);
  }
  char *api_key = getenv("CRONMOJI_KEY");
  if (!api_key) {
    fprintf(stderr, "couldn't get api key from %s\n", "CRONMOJI_KEY");
    exit(1);
  }
  char buf_tpl[256] = {0};
  tpl_build_rand(buf_tpl, sizeof(buf_tpl));
  char buf_auth[128] = {0};
  char buf_post[512] = {0};
  req_build_auth(buf_auth, sizeof(buf_auth), api_email, api_key);
  req_build_post(buf_post, sizeof(buf_post), argv[1], argv[2], buf_tpl);
  req_send(buf_auth, buf_post);
  printf("%s\n", buf_tpl);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3a0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11d9 <main+0x49>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe36(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
lea    0xe3e(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    121a <main+0x8a>
mov    0x2de5(%rip),%rax
mov    (%rax),%edi
lea    0xe29(%rip),%rsi
lea    0xe13(%rip),%rdx
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
lea    0xe29(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    125b <main+0xcb>
mov    0x2da4(%rip),%rax
mov    (%rax),%edi
lea    0xe12(%rip),%rsi
lea    0xdfe(%rip),%rdx
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
lea    -0x120(%rbp),%rdi
mov    $0x100,%esi
call   10a0 <tpl_build_rand@plt>
lea    -0x1a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1060 <memset@plt>
lea    -0x3a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1060 <memset@plt>
lea    -0x1a0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0x80,%esi
call   1070 <req_build_auth@plt>
lea    -0x3a0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rcx
lea    -0x120(%rbp),%r8
mov    $0x200,%esi
call   1090 <req_build_post@plt>
lea    -0x1a0(%rbp),%rdi
lea    -0x3a0(%rbp),%rsi
call   1040 <req_send@plt>
lea    -0x120(%rbp),%rsi
lea    0xd3f(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x3a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x388,%rsp
mov    %rsi,%r14
cmp    $0x3,%edi
jne    1312 <main+0x182>
lea    0xe6a(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1327 <main+0x197>
mov    %rax,%r15
lea    0xe7e(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1340 <main+0x1b0>
mov    %rax,%rbx
xorps  %xmm0,%xmm0
movaps %xmm0,0x170(%rsp)
movaps %xmm0,0x160(%rsp)
movaps %xmm0,0x150(%rsp)
movaps %xmm0,0x140(%rsp)
movaps %xmm0,0x130(%rsp)
movaps %xmm0,0x120(%rsp)
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
lea    0x80(%rsp),%r12
mov    %r12,%rdi
mov    $0x100,%esi
call   10a0 <tpl_build_rand@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    0x180(%rsp),%r13
mov    $0x200,%edx
mov    %r13,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    $0x80,%esi
mov    %r15,%rdx
mov    %rbx,%rcx
call   1070 <req_build_auth@plt>
mov    0x8(%r14),%rdx
mov    0x10(%r14),%rcx
mov    %r13,%rdi
mov    $0x200,%esi
mov    %r12,%r8
call   1090 <req_build_post@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
call   1040 <req_send@plt>
lea    0xd50(%rip),%rdi
mov    %r12,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x388,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cc7(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xcdb(%rip),%rsi
jmp    1357 <main+0x1c7>
mov    0x2cb2(%rip),%rax
mov    (%rax),%edi
lea    0xcf6(%rip),%rsi
lea    0xce0(%rip),%rdx
jmp    1357 <main+0x1c7>
mov    0x2c99(%rip),%rax
mov    (%rax),%edi
lea    0xd07(%rip),%rsi
lea    0xcf3(%rip),%rdx
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [30 x i8] c"usage: %s <stream> <subject>\0A\00"
@.str.1 = [15 x i8] c"CRONMOJI_EMAIL\00"
@.str.2 = [29 x i8] c"couldn't get e-mail from %s\0A\00"
@.str.3 = [13 x i8] c"CRONMOJI_KEY\00"
@.str.4 = [30 x i8] c"couldn't get api key from %s\0A\00"
@.str.5 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [256 x i8]
%9 = alloca [128 x i8]
%10 = alloca [512 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 3
br i1 %12, label %13, label %20
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %2
%21 = call i8* @getenv(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
store i8* %21, i8** %6
%22 = load i8*, i8** %6
%23 = icmp ne i8* %22, null
br i1 %23, label %28, label %24
24: ; preds = %20
%25 = load i32, i32* @stderr
%26 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %20
%29 = call i8* @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
store i8* %29, i8** %7
%30 = load i8*, i8** %7
%31 = icmp ne i8* %30, null
br i1 %31, label %36, label %32
32: ; preds = %28
%33 = load i32, i32* @stderr
%34 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %28
%37 = bitcast [256 x i8]* %8 to i8*
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%39 = call i32 @tpl_build_rand(i8* %38, i32 256)
%40 = bitcast [128 x i8]* %9 to i8*
%41 = bitcast [512 x i8]* %10 to i8*
%42 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%43 = load i8*, i8** %6
%44 = load i8*, i8** %7
%45 = call i32 @req_build_auth(i8* %42, i32 128, i8* %43, i8* %44)
%46 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 1
%49 = load i8*, i8** %48
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 2
%52 = load i8*, i8** %51
%53 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%54 = call i32 @req_build_post(i8* %46, i32 512, i8* %49, i8* %52, i8* %53)
%55 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%56 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%57 = call i32 @req_send(i8* %55, i8* %56)
%58 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%59 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %58)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [30 x i8] c"usage: %s <stream> <subject>\0A\00"
@.str.1 = [15 x i8] c"CRONMOJI_EMAIL\00"
@.str.2 = [29 x i8] c"couldn't get e-mail from %s\0A\00"
@.str.3 = [13 x i8] c"CRONMOJI_KEY\00"
@.str.4 = [30 x i8] c"couldn't get api key from %s\0A\00"
@.str.5 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = alloca [128 x i8]
%5 = alloca [512 x i8]
%6 = icmp eq i32 %0, 3
br i1 %6, label %12, label %7
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %1
%10 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = tail call i8* @getenv(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %12
%20 = tail call i8* @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = load i32, i32* @stderr
%24 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%25 = tail call i32 @exit(i32 1)
unreachable
26: ; preds = %19
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%28 = call i32 @tpl_build_rand(i8* %27, i32 256)
%29 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%30 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%31 = call i32 @req_build_auth(i8* %29, i32 128, i8* %13, i8* %20)
%32 = getelementptr inbounds i8*, i8** %1, i64 1
%33 = load i8*, i8** %32
%34 = getelementptr inbounds i8*, i8** %1, i64 2
%35 = load i8*, i8** %34
%36 = call i32 @req_build_post(i8* %30, i32 512, i8* %33, i8* %35, i8* %27)
%37 = call i32 @req_send(i8* %29, i8* %30)
%38 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %27)
ret i32 0
}