#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ system(char *);
void sendMessage(char *message, int num) {
  FILE *fp2;
  fp2 = fopen("message.dat", "w");
  fputs("{\n", fp2);
  fputs("\"bot_id\" : \"insert bot ID here\",\n", fp2);
  if (num < 30) {
    fputs("\"text\" : \"", fp2);
    fputs(message, fp2);
    fputs("\"\n", fp2);
  } else {
    fputs("\"attachments\" : [\n{\n", fp2);
    fputs("\"type\" : \"image\",\n", fp2);
    fputs("\"url\" : \"", fp2);
    fputs(message, fp2);
    fputs("\"\n}\n]\n", fp2);
  }
  fputs("}", fp2);
  fclose(fp2);
  system("curl -d @message.dat https://api.groupme.com/v3/bots/post");
}


x86 assembly (clang, -O0):
<sendMessage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeaa(%rip),%rdi
lea    0xeaf(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xedf(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x18(%rbp),%rsi
lea    0xe8d(%rip),%rdi
call   1050 <fputs@plt>
cmpl   $0x1e,-0xc(%rbp)
jge    11c2 <sendMessage+0x82>
mov    -0x18(%rbp),%rsi
lea    0xe95(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <fputs@plt>
mov    -0x18(%rbp),%rsi
lea    0xe83(%rip),%rdi
call   1050 <fputs@plt>
jmp    120f <sendMessage+0xcf>
mov    -0x18(%rbp),%rsi
lea    0xe71(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x18(%rbp),%rsi
lea    0xe76(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x18(%rbp),%rsi
lea    0xe79(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <fputs@plt>
mov    -0x18(%rbp),%rsi
lea    0xe66(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x18(%rbp),%rsi
lea    0xe5d(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe4a(%rip),%rdi
call   1040 <system@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendMessage>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r14
lea    0xe90(%rip),%rdi
lea    0xe95(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xeca(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1080 <fwrite@plt>
lea    0xe6f(%rip),%rdi
mov    $0x21,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
cmp    $0x1d,%ebp
jg     11e8 <sendMessage+0x88>
lea    0xe73(%rip),%rdi
mov    $0xa,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <fputs@plt>
lea    0xe5a(%rip),%rdi
mov    $0x2,%esi
jmp    124a <sendMessage+0xea>
lea    0xe4f(%rip),%rdi
mov    $0x14,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
lea    0xe4b(%rip),%rdi
mov    $0x12,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
lea    0xe45(%rip),%rdi
mov    $0x9,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <fputs@plt>
lea    0xe2b(%rip),%rdi
mov    $0x6,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
mov    $0x7d,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xe04(%rip),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <system@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"message.dat\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [3 x i8] c"{\0A\00"
@.str.3 = [34 x i8] c"\22bot_id\22 : \22insert bot ID here\22,\0A\00"
@.str.4 = [11 x i8] c"\22text\22 : \22\00"
@.str.5 = [3 x i8] c"\22\0A\00"
@.str.6 = [21 x i8] c"\22attachments\22 : [\0A{\0A\00"
@.str.7 = [19 x i8] c"\22type\22 : \22image\22,\0A\00"
@.str.8 = [10 x i8] c"\22url\22 : \22\00"
@.str.9 = [7 x i8] c"\22\0A}\0A]\0A\00"
@.str.10 = [2 x i8] c"}\00"
@.str.11 = [58 x i8] c"curl -d @message.dat https://api.groupme.com/v3/bots/post\00"
define void @sendMessage(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32*
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %5
%7 = load i32*, i32** %5
%8 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%9 = load i32*, i32** %5
%10 = call i32 @fputs(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32* %9)
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 30
br i1 %12, label %13, label %21
13: ; preds = %2
%14 = load i32*, i32** %5
%15 = call i32 @fputs(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32* %14)
%16 = load i8*, i8** %3
%17 = load i32*, i32** %5
%18 = call i32 @fputs(i8* %16, i32* %17)
%19 = load i32*, i32** %5
%20 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %19)
br label %33
21: ; preds = %2
%22 = load i32*, i32** %5
%23 = call i32 @fputs(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i32* %22)
%24 = load i32*, i32** %5
%25 = call i32 @fputs(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i32* %24)
%26 = load i32*, i32** %5
%27 = call i32 @fputs(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i32* %26)
%28 = load i8*, i8** %3
%29 = load i32*, i32** %5
%30 = call i32 @fputs(i8* %28, i32* %29)
%31 = load i32*, i32** %5
%32 = call i32 @fputs(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i32* %31)
br label %33
33: ; preds = %21, %13
%34 = load i32*, i32** %5
%35 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i32* %34)
%36 = load i32*, i32** %5
%37 = call i32 @fclose(i32* %36)
%38 = call i32 @system(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.11, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"message.dat\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [3 x i8] c"{\0A\00"
@.str.3 = [34 x i8] c"\22bot_id\22 : \22insert bot ID here\22,\0A\00"
@.str.4 = [11 x i8] c"\22text\22 : \22\00"
@.str.5 = [3 x i8] c"\22\0A\00"
@.str.6 = [21 x i8] c"\22attachments\22 : [\0A{\0A\00"
@.str.7 = [19 x i8] c"\22type\22 : \22image\22,\0A\00"
@.str.8 = [10 x i8] c"\22url\22 : \22\00"
@.str.9 = [7 x i8] c"\22\0A}\0A]\0A\00"
@.str.11 = [58 x i8] c"curl -d @message.dat https://api.groupme.com/v3/bots/post\00"
define void @sendMessage(i8* nocapture %0, i32 %1) {
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i64 2, i64 1, i32* %3)
%5 = tail call i64 @fwrite(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i64 33, i64 1, i32* %3)
%6 = icmp slt i32 %1, 30
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i64 10, i64 1, i32* %3)
%9 = tail call i32 @fputs(i8* %0, i32* %3)
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i64 2, i64 1, i32* %3)
br label %17
11: ; preds = %2
%12 = tail call i64 @fwrite(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i64 20, i64 1, i32* %3)
%13 = tail call i64 @fwrite(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i64 18, i64 1, i32* %3)
%14 = tail call i64 @fwrite(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i64 9, i64 1, i32* %3)
%15 = tail call i32 @fputs(i8* %0, i32* %3)
%16 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i64 6, i64 1, i32* %3)
br label %17
17: ; preds = %11, %7
%18 = tail call i32 @fputc(i32 125, i32* %3)
%19 = tail call i32 @fclose(i32* %3)
%20 = tail call i32 @system(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.11, i64 0, i64 0))
ret void
}