#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*/ asprintf(char **, char *, char *, ...);
int /*<<< orphan*/ printf(char *);
int read(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ system(char *);
int main(int argc, char **argv) {
  char *command;
  char *mobile;
  char buf[1024];
  if (argc != 2) {
    printf("");
    return (1);
  }
  asprintf(&mobile, "%s", argv[1]);
  int length = 0;
  if ((length = read(0, buf, 1024)) < 0) {
    return -1;
  }
  buf[length] = '\0';
  asprintf(&command,
           "test -e /usr/bin/gnokii && echo \"%s\" | gnokii --sendsms %s > "
           "/dev/null  2>&1",
           buf, mobile);
  system(command);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     117b <main+0x3b>
lea    0xee5(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1209 <main+0xc9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    -0x20(%rbp),%rdi
lea    0xe72(%rip),%rsi
mov    $0x0,%al
call   1060 <asprintf@plt>
movl   $0x0,-0x424(%rbp)
lea    -0x420(%rbp),%rsi
xor    %edi,%edi
mov    $0x400,%edx
call   1050 <read@plt>
mov    %eax,-0x424(%rbp)
cmp    $0x0,%eax
jge    11cd <main+0x8d>
movl   $0xffffffff,-0x4(%rbp)
jmp    1209 <main+0xc9>
movslq -0x424(%rbp),%rax
movb   $0x0,-0x420(%rbp,%rax,1)
lea    -0x420(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    -0x18(%rbp),%rdi
lea    0xe11(%rip),%rsi
mov    $0x0,%al
call   1060 <asprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <system@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x410,%rsp
mov    $0x1,%ebx
cmp    $0x2,%edi
jne    11a2 <main+0x72>
mov    0x8(%rsi),%rdx
lea    0xeb3(%rip),%rsi
xor    %ebx,%ebx
mov    %rsp,%rdi
xor    %eax,%eax
call   1050 <asprintf@plt>
lea    0x10(%rsp),%rsi
xor    %edi,%edi
mov    $0x400,%edx
call   1040 <read@plt>
test   %eax,%eax
js     119d <main+0x6d>
mov    %eax,%eax
movb   $0x0,0x10(%rsp,%rax,1)
mov    (%rsp),%rcx
lea    0xe83(%rip),%rsi
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1050 <asprintf@plt>
mov    0x8(%rsp),%rdi
call   1030 <system@plt>
jmp    11a2 <main+0x72>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x410,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [77 x i8] c"test -e /usr/bin/gnokii && echo \22%s\22 | gnokii --sendsms %s > /dev/null 2>&1\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 [1024 x i8]
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @printf(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %32
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 (i8**, i8*, i8*, ...) @asprintf(i8** %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %17)
store i32 0, i32* %9
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%20 = call i32 @read(i32 0, i8* %19, i32 1024)
store i32 %20, i32* %9
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %14
store i32 -1, i32* %3
br label %32
23: ; preds = %14
%24 = load i32, i32* %9
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 %25
store i8 0, i8* %26
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%28 = load i8*, i8** %7
%29 = call i32 (i8**, i8*, i8*, ...) @asprintf(i8** %6, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.2, i64 0, i64 0), i8* %27, i8* %28)
%30 = load i8*, i8** %6
%31 = call i32 @system(i8* %30)
store i32 0, i32* %3
br label %32
32: ; preds = %23, %22, %12
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [77 x i8] c"test -e /usr/bin/gnokii && echo \22%s\22 | gnokii --sendsms %s > /dev/null 2>&1\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [1024 x i8]
%6 = bitcast i8** %3 to i8*
%7 = bitcast i8** %4 to i8*
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%9 = icmp eq i32 %0, 2
br i1 %9, label %10, label %23
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = call i32 (i8**, i8*, i8*, ...) @asprintf(i8** %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = call i32 @read(i32 0, i8* %8, i32 1024)
%15 = icmp slt i32 %14, 0
br i1 %15, label %23, label %16
16: ; preds = %10
%17 = zext i32 %14 to i64
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %17
store i8 0, i8* %18
%19 = load i8*, i8** %4
%20 = call i32 (i8**, i8*, i8*, ...) @asprintf(i8** %3, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.2, i64 0, i64 0), i8* %8, i8* %19)
%21 = load i8*, i8** %3
%22 = call i32 @system(i8* %21)
br label %23
23: ; preds = %16, %10, %2
%24 = phi i32 [ 1, %2 ], [ 0, %16 ], [ -1, %10 ]
ret i32 %24
}