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

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ free(unsigned char *);
unsigned char *malloc(int);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
int main(int argc, char **argv) {
  FILE *output_device;
  char target_phone[12];
  unsigned char *sms_string;
  int i, l, m, n;
  int intext_length, sms_string_length;
  if (argc != 4) {
    printf("usage: %s </dev/device> <phone-no> <sms text>\n", argv[0]);
    exit(-1);
  }
  i = strlen((argv[2]));
  if (i == 11 && (argv[2])[0] == '0') {
    target_phone[0] = '4';
    target_phone[1] = '4';
    memcpy(target_phone + 2, (argv[2]) + 1, 10);
  } else if (i == 12) {
    memcpy(target_phone, (argv[2]), 12);
  } else if (i == 13 && (argv[2])[0] == '+') {
    memcpy(target_phone, (argv[2]) + 1, 12);
  } else {
    printf("Invalid length for phone number '%s': %i\n", (argv[2]), i);
    exit(-1);
  }
  for (i = 0; i < 12; i++) {
    if (target_phone[i] < '0' || target_phone[i] > '9') {
      if (((unsigned char)target_phone[i]) < 32 ||
          ((unsigned char)target_phone[i]) > 126)
        printf("Invalid char in phone number: 0x'%.2X'\n",
               (unsigned char)target_phone[i]);
      else
        printf("Invalid char in phone number: '%c'\n", target_phone[i]);
      exit(-1);
    }
  }
  intext_length = strlen((argv[3]));
  if (intext_length > 160) {
    printf("Text is too long at %i chars. Max is 160.\n", i);
    exit(-1);
  }
  if (intext_length < 1) {
    printf("No text supplied for the SMS.\n");
    exit(-1);
  }
  i = intext_length * 7;
  m = i % 8;
  if (m != 0)
    i += (8 - m);
  sms_string_length = i / 8;
  sms_string = malloc(sms_string_length);
  if (sms_string == NULL) {
    printf("Unable to malloc '%i' bytes for variable 'sms_string'\n",
           sms_string_length);
    exit(-1);
  }
  memset(sms_string, 0, sms_string_length);
  l = 1;
  m = 0;
  for (i = 0; i < intext_length; i++) {
    if (((unsigned char)(argv[3])[i]) < 32 ||
        ((unsigned char)(argv[3])[i]) > 126) {
      printf("Invalid character in text input: 0x'%.2X'\n",
             (unsigned char)(argv[3])[i]);
      exit(-1);
    }
    if ((argv[3])[i] == '$') {
      (argv[3])[i] = 0x02;
    }
    for (n = 0; n < 7; n++) {
      if (((unsigned char)(argv[3])[i]) & (1 << n)) {
        sms_string[m] |= l;
      }
      l = l << 1;
      if (l == 256) {
        l = 1;
        m++;
      }
    }
  }
  output_device = fopen((argv[1]), "wb");
  if (output_device == NULL) {
    perror("Unable to open output device");
    exit(-1);
  }
  fprintf(output_device, "AT+CMGF=0\r\n");
  fflush(output_device);
  fprintf(output_device, "AT+CMGS=%i\r\n", 14 + sms_string_length);
  fflush(output_device);
  fprintf(output_device, "0011000C91");
  for (i = 0; i < 12; i += 2) {
    fprintf(output_device, "%c%c", target_phone[i + 1], target_phone[i]);
  }
  fprintf(output_device, "0000AA");
  fprintf(output_device, "%.2X", intext_length);
  for (i = 0; i < sms_string_length; i++)
    fprintf(output_device, "%.2X", sms_string[i]);
  fprintf(output_device, "%c", 0x1a);
  fflush(output_device);
  fclose(output_device);
  free(sms_string);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     11ff <main+0x3f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   10e0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0xb,-0x34(%rbp)
jne    1258 <main+0x98>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jne    1258 <main+0x98>
movb   $0x34,-0x24(%rbp)
movb   $0x34,-0x23(%rbp)
lea    -0x24(%rbp),%rdi
add    $0x2,%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
add    $0x1,%rsi
mov    $0xa,%edx
call   1090 <memcpy@plt>
jmp    12e7 <main+0x127>
cmpl   $0xc,-0x34(%rbp)
jne    127d <main+0xbd>
lea    -0x24(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    $0xc,%edx
call   1090 <memcpy@plt>
jmp    12e2 <main+0x122>
cmpl   $0xd,-0x34(%rbp)
jne    12ba <main+0xfa>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
jne    12ba <main+0xfa>
lea    -0x24(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
add    $0x1,%rsi
mov    $0xc,%edx
call   1090 <memcpy@plt>
jmp    12dd <main+0x11d>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    -0x34(%rbp),%edx
lea    0xd63(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   10e0 <exit@plt>
jmp    12e2 <main+0x122>
jmp    12e7 <main+0x127>
movl   $0x0,-0x34(%rbp)
cmpl   $0xc,-0x34(%rbp)
jge    1390 <main+0x1d0>
movslq -0x34(%rbp),%rax
movsbl -0x24(%rbp,%rax,1),%eax
cmp    $0x30,%eax
jl     131c <main+0x15c>
movslq -0x34(%rbp),%rax
movsbl -0x24(%rbp,%rax,1),%eax
cmp    $0x39,%eax
jle    137d <main+0x1bd>
movslq -0x34(%rbp),%rax
movzbl -0x24(%rbp,%rax,1),%eax
cmp    $0x20,%eax
jl     1340 <main+0x180>
movslq -0x34(%rbp),%rax
movzbl -0x24(%rbp,%rax,1),%eax
cmp    $0x7e,%eax
jle    135c <main+0x19c>
movslq -0x34(%rbp),%rax
movzbl -0x24(%rbp,%rax,1),%esi
lea    0xd09(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1373 <main+0x1b3>
movslq -0x34(%rbp),%rax
movsbl -0x24(%rbp,%rax,1),%esi
lea    0xd15(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   10e0 <exit@plt>
jmp    1382 <main+0x1c2>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    12ee <main+0x12e>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0xa0,-0x44(%rbp)
jle    13c8 <main+0x208>
mov    -0x34(%rbp),%esi
lea    0xcee(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   10e0 <exit@plt>
cmpl   $0x1,-0x44(%rbp)
jge    13ea <main+0x22a>
lea    0xcf7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   10e0 <exit@plt>
imul   $0x7,-0x44(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
je     1417 <main+0x257>
mov    $0x8,%eax
sub    -0x3c(%rbp),%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%edi
call   10a0 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1457 <main+0x297>
mov    -0x48(%rbp),%esi
lea    0xca9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   10e0 <exit@plt>
mov    -0x30(%rbp),%rdi
mov    -0x48(%rbp),%edx
xor    %esi,%esi
call   1070 <memset@plt>
movl   $0x1,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    15a1 <main+0x3e1>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movslq -0x34(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jl     14b8 <main+0x2f8>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movslq -0x34(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x7e,%eax
jle    14e0 <main+0x320>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movslq -0x34(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xc57(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   10e0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movslq -0x34(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x24,%eax
jne    1509 <main+0x349>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movslq -0x34(%rbp),%rcx
movb   $0x2,(%rax,%rcx,1)
movl   $0x0,-0x40(%rbp)
cmpl   $0x7,-0x40(%rbp)
jge    158e <main+0x3ce>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movslq -0x34(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    -0x40(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1555 <main+0x395>
mov    -0x38(%rbp),%esi
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
or     %esi,%edx
mov    %dl,(%rax,%rcx,1)
mov    -0x38(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x38(%rbp)
cmpl   $0x100,-0x38(%rbp)
jne    157b <main+0x3bb>
movl   $0x1,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1580 <main+0x3c0>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1510 <main+0x350>
jmp    1593 <main+0x3d3>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    147a <main+0x2ba>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xba1(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    15da <main+0x41a>
lea    0xb89(%rip),%rdi
call   10d0 <perror@plt>
mov    $0xffffffff,%edi
call   10e0 <exit@plt>
mov    -0x18(%rbp),%rdi
lea    0xb8c(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   10b0 <fflush@plt>
mov    -0x18(%rbp),%rdi
mov    -0x48(%rbp),%edx
add    $0xe,%edx
lea    0xb77(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   10b0 <fflush@plt>
mov    -0x18(%rbp),%rdi
lea    0xb69(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0xc,-0x34(%rbp)
jge    166f <main+0x4af>
mov    -0x18(%rbp),%rdi
mov    -0x34(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x24(%rbp,%rax,1),%edx
movslq -0x34(%rbp),%rax
movsbl -0x24(%rbp,%rax,1),%ecx
lea    0xb3b(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x34(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x34(%rbp)
jmp    162f <main+0x46f>
mov    -0x18(%rbp),%rdi
lea    0xb20(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x44(%rbp),%edx
lea    0xb12(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x48(%rbp),%eax
jge    16d5 <main+0x515>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xae1(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    169d <main+0x4dd>
mov    -0x18(%rbp),%rdi
lea    0xab7(%rip),%rsi
mov    $0x1a,%edx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   10b0 <fflush@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
cmp    $0x4,%edi
jne    16f9 <main+0x509>
mov    0x10(%r14),%rdi
call   1060 <strlen@plt>
cmp    $0xb,%eax
je     1239 <main+0x49>
cmp    $0xc,%eax
je     125d <main+0x6d>
cmp    $0xd,%eax
jne    1759 <main+0x569>
mov    0x10(%r14),%rsi
cmpb   $0x2b,(%rsi)
jne    175d <main+0x56d>
add    $0x1,%rsi
jmp    1261 <main+0x71>
mov    0x10(%r14),%rsi
cmpb   $0x30,(%rsi)
jne    175d <main+0x56d>
movw   $0x3434,0x4(%rsp)
lea    0x6(%rsp),%rdi
add    $0x1,%rsi
mov    $0xa,%edx
jmp    126b <main+0x7b>
mov    0x10(%r14),%rsi
lea    0x4(%rsp),%rdi
mov    $0xc,%edx
call   10b0 <memcpy@plt>
mov    0x4(%rsp),%al
lea    -0x3a(%rax),%ecx
cmp    $0xf5,%cl
jbe    16cd <main+0x4dd>
mov    0x5(%rsp),%al
lea    -0x3a(%rax),%ecx
cmp    $0xf6,%cl
jb     16cd <main+0x4dd>
mov    0x6(%rsp),%al
lea    -0x3a(%rax),%ecx
cmp    $0xf6,%cl
jb     16cd <main+0x4dd>
mov    0x7(%rsp),%al
lea    -0x3a(%rax),%ecx
cmp    $0xf6,%cl
jb     16cd <main+0x4dd>
mov    0x8(%rsp),%al
lea    -0x3a(%rax),%ecx
cmp    $0xf6,%cl
jb     16cd <main+0x4dd>
mov    0x9(%rsp),%al
lea    -0x3a(%rax),%ecx
cmp    $0xf6,%cl
jb     16cd <main+0x4dd>
mov    0xa(%rsp),%al
lea    -0x3a(%rax),%ecx
cmp    $0xf6,%cl
jb     16cd <main+0x4dd>
mov    0xb(%rsp),%al
lea    -0x3a(%rax),%ecx
cmp    $0xf6,%cl
jb     16cd <main+0x4dd>
mov    0xc(%rsp),%al
lea    -0x3a(%rax),%ecx
cmp    $0xf6,%cl
jb     16cd <main+0x4dd>
mov    0xd(%rsp),%al
lea    -0x3a(%rax),%ecx
cmp    $0xf6,%cl
jb     16cd <main+0x4dd>
mov    0xe(%rsp),%al
lea    -0x3a(%rax),%ecx
cmp    $0xf6,%cl
jb     16cd <main+0x4dd>
mov    0xf(%rsp),%al
lea    -0x3a(%rax),%ecx
cmp    $0xf6,%cl
jb     16cd <main+0x4dd>
mov    0x18(%r14),%rdi
call   1060 <strlen@plt>
cmp    $0xa1,%eax
jge    1714 <main+0x524>
mov    %eax,%r13d
test   %eax,%eax
jle    1722 <main+0x532>
lea    0x0(,%r13,8),%eax
sub    %r13d,%eax
mov    %eax,%ecx
and    $0x7,%ecx
mov    $0x8,%r15d
sub    %ecx,%r15d
test   %ecx,%ecx
cmove  %ecx,%r15d
add    %eax,%r15d
mov    %r15d,%ebx
shr    $0x3,%ebx
mov    %ebx,%edi
call   10c0 <malloc@plt>
test   %rax,%rax
je     1738 <main+0x548>
mov    %rax,%r12
xor    %ebp,%ebp
mov    %rax,%rdi
xor    %esi,%esi
mov    %rbx,0x10(%rsp)
mov    %ebx,%edx
call   1080 <memset@plt>
mov    %r13d,%r8d
mov    0x18(%r14),%r9
mov    $0x1,%ebx
xor    %edx,%edx
jmp    13c2 <main+0x1d2>
nopl   (%rax)
mov    %cl,%sil
add    %esi,%edx
add    $0x1,%rbp
cmp    %rbp,%r8
je     151b <main+0x32b>
movzbl (%r9,%rbp,1),%eax
lea    -0x7f(%rax),%ecx
cmp    $0xa0,%cl
jbe    16c1 <main+0x4d1>
cmp    $0x24,%al
jne    13e5 <main+0x1f5>
movb   $0x2,(%r9,%rbp,1)
mov    0x18(%r14),%r9
movzbl (%r9,%rbp,1),%eax
test   $0x1,%al
jne    13f0 <main+0x200>
movzbl %al,%esi
jmp    13fc <main+0x20c>
xchg   %ax,%ax
movslq %edx,%rax
or     %bl,(%r12,%rax,1)
movzbl (%r9,%rbp,1),%esi
add    %ebx,%ebx
xor    %eax,%eax
mov    $0x1,%edi
cmp    $0x100,%ebx
sete   %cl
je     1412 <main+0x222>
mov    %ebx,%edi
mov    %cl,%al
add    %eax,%edx
test   $0x2,%sil
je     1428 <main+0x238>
movslq %edx,%rax
or     %dil,(%r12,%rax,1)
movzbl (%r9,%rbp,1),%esi
add    %edi,%edi
xor    %ebx,%ebx
mov    $0x1,%eax
cmp    $0x100,%edi
sete   %cl
je     143e <main+0x24e>
mov    %edi,%eax
mov    %cl,%bl
add    %ebx,%edx
test   $0x4,%sil
je     1454 <main+0x264>
movslq %edx,%rcx
or     %al,(%r12,%rcx,1)
movzbl (%r9,%rbp,1),%esi
add    %eax,%eax
xor    %ebx,%ebx
mov    $0x1,%edi
cmp    $0x100,%eax
sete   %cl
je     1469 <main+0x279>
mov    %eax,%edi
mov    %cl,%bl
add    %ebx,%edx
test   $0x8,%sil
je     147f <main+0x28f>
movslq %edx,%rax
or     %dil,(%r12,%rax,1)
movzbl (%r9,%rbp,1),%esi
add    %edi,%edi
xor    %ebx,%ebx
mov    $0x1,%eax
cmp    $0x100,%edi
sete   %cl
je     1495 <main+0x2a5>
mov    %edi,%eax
mov    %cl,%bl
add    %ebx,%edx
test   $0x10,%sil
je     14ab <main+0x2bb>
movslq %edx,%rcx
or     %al,(%r12,%rcx,1)
movzbl (%r9,%rbp,1),%esi
add    %eax,%eax
xor    %ebx,%ebx
mov    $0x1,%edi
cmp    $0x100,%eax
sete   %cl
je     14c0 <main+0x2d0>
mov    %eax,%edi
mov    %cl,%bl
add    %ebx,%edx
test   $0x20,%sil
je     14d6 <main+0x2e6>
movslq %edx,%rax
or     %dil,(%r12,%rax,1)
movzbl (%r9,%rbp,1),%esi
add    %edi,%edi
xor    %ebx,%ebx
mov    $0x1,%eax
cmp    $0x100,%edi
sete   %cl
je     14ec <main+0x2fc>
mov    %edi,%eax
mov    %cl,%bl
add    %ebx,%edx
test   $0x40,%sil
je     14fd <main+0x30d>
movslq %edx,%rcx
or     %al,(%r12,%rcx,1)
add    %eax,%eax
xor    %esi,%esi
mov    $0x1,%ebx
cmp    $0x100,%eax
sete   %cl
je     13b0 <main+0x1c0>
mov    %eax,%ebx
jmp    13b0 <main+0x1c0>
mov    %r13,%rbx
mov    0x8(%r14),%rdi
lea    0xc09(%rip),%rsi
call   10e0 <fopen@plt>
test   %rax,%rax
je     1743 <main+0x553>
mov    %rax,%r14
lea    0xc11(%rip),%rdi
mov    $0xb,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1110 <fwrite@plt>
mov    %r14,%rdi
call   10d0 <fflush@plt>
mov    0x10(%rsp),%rbp
lea    0xe(%rbp),%edx
lea    0xbf4(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %r14,%rdi
call   10d0 <fflush@plt>
lea    0xbe8(%rip),%rdi
mov    $0xa,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1110 <fwrite@plt>
movsbl 0x5(%rsp),%edx
movsbl 0x4(%rsp),%ecx
lea    0xbd0(%rip),%r13
mov    %r14,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
movsbl 0x7(%rsp),%edx
movsbl 0x6(%rsp),%ecx
mov    %r14,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
movsbl 0x9(%rsp),%edx
movsbl 0x8(%rsp),%ecx
mov    %r14,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
movsbl 0xb(%rsp),%edx
movsbl 0xa(%rsp),%ecx
mov    %r14,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
movsbl 0xd(%rsp),%edx
movsbl 0xc(%rsp),%ecx
mov    %r14,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
movsbl 0xf(%rsp),%edx
movsbl 0xe(%rsp),%ecx
mov    %r14,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
lea    0xb4e(%rip),%rdi
mov    $0x6,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1110 <fwrite@plt>
lea    0xb3c(%rip),%rsi
mov    %r14,%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   10a0 <fprintf@plt>
cmp    $0x8,%r15d
jb     168b <main+0x49b>
mov    %ebp,%ebx
lea    0xb21(%rip),%r15
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%r12,%rbp,1),%edx
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1670 <main+0x480>
mov    $0x1a,%edi
mov    %r14,%rsi
call   1090 <fputc@plt>
mov    %r14,%rdi
call   10d0 <fflush@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    %r12,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movzbl %al,%esi
lea    0xa3c(%rip),%rdi
jmp    16e8 <main+0x4f8>
lea    -0x7f(%rax),%ecx
cmp    $0xa1,%cl
movzbl %al,%esi
lea    0x97c(%rip),%rax
lea    0x99d(%rip),%rdi
cmovb  %rax,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xffffffff,%edi
call   1100 <exit@plt>
mov    (%r14),%rsi
lea    0x8fd(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xffffffff,%edi
call   1100 <exit@plt>
lea    0x98a(%rip),%rdi
mov    $0xc,%esi
jmp    16e8 <main+0x4f8>
lea    0xa5e(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%edi
call   1100 <exit@plt>
lea    0x991(%rip),%rdi
mov    %ebx,%esi
jmp    16e8 <main+0x4f8>
lea    0x9eb(%rip),%rdi
call   10f0 <perror@plt>
mov    $0xffffffff,%edi
call   1100 <exit@plt>
mov    0x10(%r14),%rsi
lea    0x8cb(%rip),%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xffffffff,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
@.str = [47 x i8] c"usage: %s </dev/device> <phone-no> <sms text>\0A\00"
@.str.1 = [42 x i8] c"Invalid length for phone number '%s': %i\0A\00"
@.str.2 = [40 x i8] c"Invalid char in phone number: 0x'%.2X'\0A\00"
@.str.3 = [36 x i8] c"Invalid char in phone number: '%c'\0A\00"
@.str.4 = [43 x i8] c"Text is too long at %i chars. Max is 160.\0A\00"
@.str.5 = [31 x i8] c"No text supplied for the SMS.\0A\00"
@.str.6 = [55 x i8] c"Unable to malloc '%i' bytes for variable 'sms_string'\0A\00"
@.str.7 = [43 x i8] c"Invalid character in text input: 0x'%.2X'\0A\00"
@.str.8 = [3 x i8] c"wb\00"
@.str.9 = [29 x i8] c"Unable to open output device\00"
@.str.10 = [12 x i8] c"AT+CMGF=0\0D\0A\00"
@.str.11 = [13 x i8] c"AT+CMGS=%i\0D\0A\00"
@.str.12 = [11 x i8] c"0011000C91\00"
@.str.13 = [5 x i8] c"%c%c\00"
@.str.14 = [7 x i8] c"0000AA\00"
@.str.15 = [5 x i8] c"%.2X\00"
@.str.16 = [3 x i8] c"%c\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [12 x i8]
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 4
br i1 %16, label %17, label %23
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = call i32 @exit(i32 -1)
unreachable
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i32 @strlen(i8* %26)
store i32 %27, i32* %9
%28 = load i32, i32* %9
%29 = icmp eq i32 %28, 11
br i1 %29, label %30, label %48
30: ; preds = %23
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 2
%33 = load i8*, i8** %32
%34 = getelementptr inbounds i8, i8* %33, i64 0
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 48
br i1 %37, label %38, label %48
38: ; preds = %30
%39 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
store i8 52, i8* %39
%40 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 1
store i8 52, i8* %40
%41 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%42 = getelementptr inbounds i8, i8* %41, i64 2
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 2
%45 = load i8*, i8** %44
%46 = getelementptr inbounds i8, i8* %45, i64 1
%47 = call i32 @memcpy(i8* %42, i8* %46, i32 10)
br label %84
48: ; preds = %30, %23
%49 = load i32, i32* %9
%50 = icmp eq i32 %49, 12
br i1 %50, label %51, label %57
51: ; preds = %48
%52 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 2
%55 = load i8*, i8** %54
%56 = call i32 @memcpy(i8* %52, i8* %55, i32 12)
br label %83
57: ; preds = %48
%58 = load i32, i32* %9
%59 = icmp eq i32 %58, 13
br i1 %59, label %60, label %75
60: ; preds = %57
%61 = load i8**, i8*** %5
%62 = getelementptr inbounds i8*, i8** %61, i64 2
%63 = load i8*, i8** %62
%64 = getelementptr inbounds i8, i8* %63, i64 0
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = icmp eq i32 %66, 43
br i1 %67, label %68, label %75
68: ; preds = %60
%69 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%70 = load i8**, i8*** %5
%71 = getelementptr inbounds i8*, i8** %70, i64 2
%72 = load i8*, i8** %71
%73 = getelementptr inbounds i8, i8* %72, i64 1
%74 = call i32 @memcpy(i8* %69, i8* %73, i32 12)
br label %82
75: ; preds = %60, %57
%76 = load i8**, i8*** %5
%77 = getelementptr inbounds i8*, i8** %76, i64 2
%78 = load i8*, i8** %77
%79 = load i32, i32* %9
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %78, i32 %79)
%81 = call i32 @exit(i32 -1)
unreachable
82: ; preds = %68
br label %83
83: ; preds = %82, %51
br label %84
84: ; preds = %83, %38
store i32 0, i32* %9
br label %85
85: ; preds = %133, %84
%86 = load i32, i32* %9
%87 = icmp slt i32 %86, 12
br i1 %87, label %88, label %136
88: ; preds = %85
%89 = load i32, i32* %9
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 %90
%92 = load i8, i8* %91
%93 = sext i8 %92 to i32
%94 = icmp slt i32 %93, 48
br i1 %94, label %102, label %95
95: ; preds = %88
%96 = load i32, i32* %9
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 %97
%99 = load i8, i8* %98
%100 = sext i8 %99 to i32
%101 = icmp sgt i32 %100, 57
br i1 %101, label %102, label %132
102: ; preds = %95, %88
%103 = load i32, i32* %9
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 %104
%106 = load i8, i8* %105
%107 = zext i8 %106 to i32
%108 = icmp slt i32 %107, 32
br i1 %108, label %116, label %109
109: ; preds = %102
%110 = load i32, i32* %9
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 %111
%113 = load i8, i8* %112
%114 = zext i8 %113 to i32
%115 = icmp sgt i32 %114, 126
br i1 %115, label %116, label %123
116: ; preds = %109, %102
%117 = load i32, i32* %9
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 %118
%120 = load i8, i8* %119
%121 = zext i8 %120 to i32
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i32 %121)
br label %130
123: ; preds = %109
%124 = load i32, i32* %9
%125 = sext i32 %124 to i64
%126 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 %125
%127 = load i8, i8* %126
%128 = sext i8 %127 to i32
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i32 %128)
br label %130
130: ; preds = %123, %116
%131 = call i32 @exit(i32 -1)
unreachable
132: ; preds = %95
br label %133
133: ; preds = %132
%134 = load i32, i32* %9
%135 = add nsw i32 %134, 1
store i32 %135, i32* %9
br label %85
136: ; preds = %85
%137 = load i8**, i8*** %5
%138 = getelementptr inbounds i8*, i8** %137, i64 3
%139 = load i8*, i8** %138
%140 = call i32 @strlen(i8* %139)
store i32 %140, i32* %13
%141 = load i32, i32* %13
%142 = icmp sgt i32 %141, 160
br i1 %142, label %143, label %147
143: ; preds = %136
%144 = load i32, i32* %9
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i32 %144)
%146 = call i32 @exit(i32 -1)
unreachable
147: ; preds = %136
%148 = load i32, i32* %13
%149 = icmp slt i32 %148, 1
br i1 %149, label %150, label %153
150: ; preds = %147
%151 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
%152 = call i32 @exit(i32 -1)
unreachable
153: ; preds = %147
%154 = load i32, i32* %13
%155 = mul nsw i32 %154, 7
store i32 %155, i32* %9
%156 = load i32, i32* %9
%157 = srem i32 %156, 8
store i32 %157, i32* %11
%158 = load i32, i32* %11
%159 = icmp ne i32 %158, 0
br i1 %159, label %160, label %165
160: ; preds = %153
%161 = load i32, i32* %11
%162 = sub nsw i32 8, %161
%163 = load i32, i32* %9
%164 = add nsw i32 %163, %162
store i32 %164, i32* %9
br label %165
165: ; preds = %160, %153
%166 = load i32, i32* %9
%167 = sdiv i32 %166, 8
store i32 %167, i32* %14
%168 = load i32, i32* %14
%169 = call i8* @malloc(i32 %168)
store i8* %169, i8** %8
%170 = load i8*, i8** %8
%171 = icmp eq i8* %170, null
br i1 %171, label %172, label %176
172: ; preds = %165
%173 = load i32, i32* %14
%174 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.6, i64 0, i64 0), i32 %173)
%175 = call i32 @exit(i32 -1)
unreachable
176: ; preds = %165
%177 = load i8*, i8** %8
%178 = load i32, i32* %14
%179 = call i32 @memset(i8* %177, i32 0, i32 %178)
store i32 1, i32* %10
store i32 0, i32* %11
store i32 0, i32* %9
br label %180
180: ; preds = %272, %176
%181 = load i32, i32* %9
%182 = load i32, i32* %13
%183 = icmp slt i32 %181, %182
br i1 %183, label %184, label %275
184: ; preds = %180
%185 = load i8**, i8*** %5
%186 = getelementptr inbounds i8*, i8** %185, i64 3
%187 = load i8*, i8** %186
%188 = load i32, i32* %9
%189 = sext i32 %188 to i64
%190 = getelementptr inbounds i8, i8* %187, i64 %189
%191 = load i8, i8* %190
%192 = zext i8 %191 to i32
%193 = icmp slt i32 %192, 32
br i1 %193, label %204, label %194
194: ; preds = %184
%195 = load i8**, i8*** %5
%196 = getelementptr inbounds i8*, i8** %195, i64 3
%197 = load i8*, i8** %196
%198 = load i32, i32* %9
%199 = sext i32 %198 to i64
%200 = getelementptr inbounds i8, i8* %197, i64 %199
%201 = load i8, i8* %200
%202 = zext i8 %201 to i32
%203 = icmp sgt i32 %202, 126
br i1 %203, label %204, label %215
204: ; preds = %194, %184
%205 = load i8**, i8*** %5
%206 = getelementptr inbounds i8*, i8** %205, i64 3
%207 = load i8*, i8** %206
%208 = load i32, i32* %9
%209 = sext i32 %208 to i64
%210 = getelementptr inbounds i8, i8* %207, i64 %209
%211 = load i8, i8* %210
%212 = zext i8 %211 to i32
%213 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.7, i64 0, i64 0), i32 %212)
%214 = call i32 @exit(i32 -1)
unreachable
215: ; preds = %194
%216 = load i8**, i8*** %5
%217 = getelementptr inbounds i8*, i8** %216, i64 3
%218 = load i8*, i8** %217
%219 = load i32, i32* %9
%220 = sext i32 %219 to i64
%221 = getelementptr inbounds i8, i8* %218, i64 %220
%222 = load i8, i8* %221
%223 = sext i8 %222 to i32
%224 = icmp eq i32 %223, 36
br i1 %224, label %225, label %232
225: ; preds = %215
%226 = load i8**, i8*** %5
%227 = getelementptr inbounds i8*, i8** %226, i64 3
%228 = load i8*, i8** %227
%229 = load i32, i32* %9
%230 = sext i32 %229 to i64
%231 = getelementptr inbounds i8, i8* %228, i64 %230
store i8 2, i8* %231
br label %232
232: ; preds = %225, %215
store i32 0, i32* %12
br label %233
233: ; preds = %268, %232
%234 = load i32, i32* %12
%235 = icmp slt i32 %234, 7
br i1 %235, label %236, label %271
236: ; preds = %233
%237 = load i8**, i8*** %5
%238 = getelementptr inbounds i8*, i8** %237, i64 3
%239 = load i8*, i8** %238
%240 = load i32, i32* %9
%241 = sext i32 %240 to i64
%242 = getelementptr inbounds i8, i8* %239, i64 %241
%243 = load i8, i8* %242
%244 = zext i8 %243 to i32
%245 = load i32, i32* %12
%246 = shl i32 1, %245
%247 = and i32 %244, %246
%248 = icmp ne i32 %247, 0
br i1 %248, label %249, label %259
249: ; preds = %236
%250 = load i32, i32* %10
%251 = load i8*, i8** %8
%252 = load i32, i32* %11
%253 = sext i32 %252 to i64
%254 = getelementptr inbounds i8, i8* %251, i64 %253
%255 = load i8, i8* %254
%256 = zext i8 %255 to i32
%257 = or i32 %256, %250
%258 = trunc i32 %257 to i8
store i8 %258, i8* %254
br label %259
259: ; preds = %249, %236
%260 = load i32, i32* %10
%261 = shl i32 %260, 1
store i32 %261, i32* %10
%262 = load i32, i32* %10
%263 = icmp eq i32 %262, 256
br i1 %263, label %264, label %267
264: ; preds = %259
store i32 1, i32* %10
%265 = load i32, i32* %11
%266 = add nsw i32 %265, 1
store i32 %266, i32* %11
br label %267
267: ; preds = %264, %259
br label %268
268: ; preds = %267
%269 = load i32, i32* %12
%270 = add nsw i32 %269, 1
store i32 %270, i32* %12
br label %233
271: ; preds = %233
br label %272
272: ; preds = %271
%273 = load i32, i32* %9
%274 = add nsw i32 %273, 1
store i32 %274, i32* %9
br label %180
275: ; preds = %180
%276 = load i8**, i8*** %5
%277 = getelementptr inbounds i8*, i8** %276, i64 1
%278 = load i8*, i8** %277
%279 = call i32* @fopen(i8* %278, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
store i32* %279, i32** %6
%280 = load i32*, i32** %6
%281 = icmp eq i32* %280, null
br i1 %281, label %282, label %285
282: ; preds = %275
%283 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0))
%284 = call i32 @exit(i32 -1)
unreachable
285: ; preds = %275
%286 = load i32*, i32** %6
%287 = call i32 (i32*, i8*, ...) @fprintf(i32* %286, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
%288 = load i32*, i32** %6
%289 = call i32 @fflush(i32* %288)
%290 = load i32*, i32** %6
%291 = load i32, i32* %14
%292 = add nsw i32 14, %291
%293 = call i32 (i32*, i8*, ...) @fprintf(i32* %290, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), i32 %292)
%294 = load i32*, i32** %6
%295 = call i32 @fflush(i32* %294)
%296 = load i32*, i32** %6
%297 = call i32 (i32*, i8*, ...) @fprintf(i32* %296, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0))
store i32 0, i32* %9
br label %298
298: ; preds = %315, %285
%299 = load i32, i32* %9
%300 = icmp slt i32 %299, 12
br i1 %300, label %301, label %318
301: ; preds = %298
%302 = load i32*, i32** %6
%303 = load i32, i32* %9
%304 = add nsw i32 %303, 1
%305 = sext i32 %304 to i64
%306 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 %305
%307 = load i8, i8* %306
%308 = sext i8 %307 to i32
%309 = load i32, i32* %9
%310 = sext i32 %309 to i64
%311 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 %310
%312 = load i8, i8* %311
%313 = sext i8 %312 to i32
%314 = call i32 (i32*, i8*, ...) @fprintf(i32* %302, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i32 %308, i32 %313)
br label %315
315: ; preds = %301
%316 = load i32, i32* %9
%317 = add nsw i32 %316, 2
store i32 %317, i32* %9
br label %298
318: ; preds = %298
%319 = load i32*, i32** %6
%320 = call i32 (i32*, i8*, ...) @fprintf(i32* %319, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i64 0, i64 0))
%321 = load i32*, i32** %6
%322 = load i32, i32* %13
%323 = call i32 (i32*, i8*, ...) @fprintf(i32* %321, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0), i32 %322)
store i32 0, i32* %9
br label %324
324: ; preds = %337, %318
%325 = load i32, i32* %9
%326 = load i32, i32* %14
%327 = icmp slt i32 %325, %326
br i1 %327, label %328, label %340
328: ; preds = %324
%329 = load i32*, i32** %6
%330 = load i8*, i8** %8
%331 = load i32, i32* %9
%332 = sext i32 %331 to i64
%333 = getelementptr inbounds i8, i8* %330, i64 %332
%334 = load i8, i8* %333
%335 = zext i8 %334 to i32
%336 = call i32 (i32*, i8*, ...) @fprintf(i32* %329, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0), i32 %335)
br label %337
337: ; preds = %328
%338 = load i32, i32* %9
%339 = add nsw i32 %338, 1
store i32 %339, i32* %9
br label %324
340: ; preds = %324
%341 = load i32*, i32** %6
%342 = call i32 (i32*, i8*, ...) @fprintf(i32* %341, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i32 26)
%343 = load i32*, i32** %6
%344 = call i32 @fflush(i32* %343)
%345 = load i32*, i32** %6
%346 = call i32 @fclose(i32* %345)
%347 = load i8*, i8** %8
%348 = call i32 @free(i8* %347)
ret i32 0
}

LLVM IR (-O2):
@.str = [47 x i8] c"usage: %s </dev/device> <phone-no> <sms text>\0A\00"
@.str.1 = [42 x i8] c"Invalid length for phone number '%s': %i\0A\00"
@.str.2 = [40 x i8] c"Invalid char in phone number: 0x'%.2X'\0A\00"
@.str.3 = [36 x i8] c"Invalid char in phone number: '%c'\0A\00"
@.str.4 = [43 x i8] c"Text is too long at %i chars. Max is 160.\0A\00"
@.str.6 = [55 x i8] c"Unable to malloc '%i' bytes for variable 'sms_string'\0A\00"
@.str.7 = [43 x i8] c"Invalid character in text input: 0x'%.2X'\0A\00"
@.str.8 = [3 x i8] c"wb\00"
@.str.9 = [29 x i8] c"Unable to open output device\00"
@.str.10 = [12 x i8] c"AT+CMGF=0\0D\0A\00"
@.str.11 = [13 x i8] c"AT+CMGS=%i\0D\0A\00"
@.str.12 = [11 x i8] c"0011000C91\00"
@.str.13 = [5 x i8] c"%c%c\00"
@.str.14 = [7 x i8] c"0000AA\00"
@.str.15 = [5 x i8] c"%.2X\00"
@str = [30 x i8] c"No text supplied for the SMS.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [12 x i8]
%4 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 4
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = tail call i32 @exit(i32 -1)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call i32 @strlen(i8* %12)
switch i32 %13, label %14 [
i32 11, label %16
i32 12, label %25
i32 13, label %28
]
14: ; preds = %10
%15 = load i8*, i8** %11
br label %35
16: ; preds = %10
%17 = load i8*, i8** %11
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 48
br i1 %19, label %20, label %35
20: ; preds = %16
store i8 52, i8* %4
%21 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 1
store i8 52, i8* %21
%22 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 2
%23 = getelementptr inbounds i8, i8* %17, i64 1
%24 = call i32 @memcpy(i8* %22, i8* %23, i32 10)
br label %39
25: ; preds = %10
%26 = load i8*, i8** %11
%27 = call i32 @memcpy(i8* %4, i8* %26, i32 12)
br label %39
28: ; preds = %10
%29 = load i8*, i8** %11
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 43
br i1 %31, label %32, label %35
32: ; preds = %28
%33 = getelementptr inbounds i8, i8* %29, i64 1
%34 = call i32 @memcpy(i8* %4, i8* %33, i32 12)
br label %39
35: ; preds = %14, %16, %28
%36 = phi i8* [ %15, %14 ], [ %17, %16 ], [ %29, %28 ]
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %36, i32 %13)
%38 = tail call i32 @exit(i32 -1)
unreachable
39: ; preds = %25, %32, %20
%40 = load i8, i8* %4
%41 = add i8 %40, -58
%42 = icmp ult i8 %41, -10
br i1 %42, label %43, label %51
43: ; preds = %101, %96, %91, %86, %81, %76, %71, %66, %61, %56, %51, %39
%44 = phi i8 [ %40, %39 ], [ %53, %51 ], [ %58, %56 ], [ %63, %61 ], [ %68, %66 ], [ %73, %71 ], [ %78, %76 ], [ %83, %81 ], [ %88, %86 ], [ %93, %91 ], [ %98, %96 ], [ %103, %101 ]
%45 = add i8 %44, -127
%46 = icmp ult i8 %45, -95
%47 = zext i8 %44 to i32
%48 = select i1 %46, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0)
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %48, i32 %47)
%50 = call i32 @exit(i32 -1)
unreachable
51: ; preds = %39
%52 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 1
%53 = load i8, i8* %52
%54 = add i8 %53, -58
%55 = icmp ult i8 %54, -10
br i1 %55, label %43, label %56
56: ; preds = %51
%57 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 2
%58 = load i8, i8* %57
%59 = add i8 %58, -58
%60 = icmp ult i8 %59, -10
br i1 %60, label %43, label %61
61: ; preds = %56
%62 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 3
%63 = load i8, i8* %62
%64 = add i8 %63, -58
%65 = icmp ult i8 %64, -10
br i1 %65, label %43, label %66
66: ; preds = %61
%67 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 4
%68 = load i8, i8* %67
%69 = add i8 %68, -58
%70 = icmp ult i8 %69, -10
br i1 %70, label %43, label %71
71: ; preds = %66
%72 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 5
%73 = load i8, i8* %72
%74 = add i8 %73, -58
%75 = icmp ult i8 %74, -10
br i1 %75, label %43, label %76
76: ; preds = %71
%77 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 6
%78 = load i8, i8* %77
%79 = add i8 %78, -58
%80 = icmp ult i8 %79, -10
br i1 %80, label %43, label %81
81: ; preds = %76
%82 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 7
%83 = load i8, i8* %82
%84 = add i8 %83, -58
%85 = icmp ult i8 %84, -10
br i1 %85, label %43, label %86
86: ; preds = %81
%87 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 8
%88 = load i8, i8* %87
%89 = add i8 %88, -58
%90 = icmp ult i8 %89, -10
br i1 %90, label %43, label %91
91: ; preds = %86
%92 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 9
%93 = load i8, i8* %92
%94 = add i8 %93, -58
%95 = icmp ult i8 %94, -10
br i1 %95, label %43, label %96
96: ; preds = %91
%97 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 10
%98 = load i8, i8* %97
%99 = add i8 %98, -58
%100 = icmp ult i8 %99, -10
br i1 %100, label %43, label %101
101: ; preds = %96
%102 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 11
%103 = load i8, i8* %102
%104 = add i8 %103, -58
%105 = icmp ult i8 %104, -10
br i1 %105, label %43, label %106
106: ; preds = %101
%107 = getelementptr inbounds i8*, i8** %1, i64 3
%108 = load i8*, i8** %107
%109 = call i32 @strlen(i8* %108)
%110 = icmp sgt i32 %109, 160
br i1 %110, label %111, label %114
111: ; preds = %106
%112 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i32 12)
%113 = call i32 @exit(i32 -1)
unreachable
114: ; preds = %106
%115 = icmp slt i32 %109, 1
br i1 %115, label %116, label %119
116: ; preds = %114
%117 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%118 = call i32 @exit(i32 -1)
unreachable
119: ; preds = %114
%120 = mul nuw nsw i32 %109, 7
%121 = and i32 %120, 7
%122 = icmp eq i32 %121, 0
%123 = sub nuw nsw i32 8, %121
%124 = select i1 %122, i32 0, i32 %123
%125 = add nuw nsw i32 %124, %120
%126 = lshr i32 %125, 3
%127 = call i8* @malloc(i32 %126)
%128 = icmp eq i8* %127, null
br i1 %128, label %129, label %132
129: ; preds = %119
%130 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.6, i64 0, i64 0), i32 %126)
%131 = call i32 @exit(i32 -1)
unreachable
132: ; preds = %119
%133 = call i32 @memset(i8* %127, i32 0, i32 %126)
%134 = zext i32 %109 to i64
%135 = load i8*, i8** %107
br label %136
136: ; preds = %132, %270
%137 = phi i8* [ %135, %132 ], [ %157, %270 ]
%138 = phi i64 [ 0, %132 ], [ %276, %270 ]
%139 = phi i32 [ 1, %132 ], [ %275, %270 ]
%140 = phi i32 [ 0, %132 ], [ %274, %270 ]
%141 = getelementptr inbounds i8, i8* %137, i64 %138
%142 = load i8, i8* %141
%143 = add i8 %142, -127
%144 = icmp ult i8 %143, -95
br i1 %144, label %145, label %149
145: ; preds = %136
%146 = zext i8 %142 to i32
%147 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.7, i64 0, i64 0), i32 %146)
%148 = call i32 @exit(i32 -1)
unreachable
149: ; preds = %136
%150 = icmp eq i8 %142, 36
br i1 %150, label %151, label %155
151: ; preds = %149
store i8 2, i8* %141
%152 = load i8*, i8** %107
%153 = getelementptr inbounds i8, i8* %152, i64 %138
%154 = load i8, i8* %153
br label %155
155: ; preds = %151, %149
%156 = phi i8 [ %154, %151 ], [ %142, %149 ]
%157 = phi i8* [ %152, %151 ], [ %137, %149 ]
%158 = getelementptr inbounds i8, i8* %157, i64 %138
%159 = zext i8 %156 to i32
%160 = and i32 %159, 1
%161 = icmp eq i32 %160, 0
br i1 %161, label %170, label %162
162: ; preds = %155
%163 = sext i32 %140 to i64
%164 = getelementptr inbounds i8, i8* %127, i64 %163
%165 = load i8, i8* %164
%166 = trunc i32 %139 to i8
%167 = or i8 %165, %166
store i8 %167, i8* %164
%168 = load i8, i8* %158
%169 = zext i8 %168 to i32
br label %170
170: ; preds = %162, %155
%171 = phi i32 [ %169, %162 ], [ %159, %155 ]
%172 = shl i32 %139, 1
%173 = icmp eq i32 %172, 256
%174 = zext i1 %173 to i32
%175 = add nsw i32 %140, %174
%176 = select i1 %173, i32 1, i32 %172
%177 = and i32 %171, 2
%178 = icmp eq i32 %177, 0
br i1 %178, label %187, label %179
179: ; preds = %170
%180 = sext i32 %175 to i64
%181 = getelementptr inbounds i8, i8* %127, i64 %180
%182 = load i8, i8* %181
%183 = trunc i32 %176 to i8
%184 = or i8 %182, %183
store i8 %184, i8* %181
%185 = load i8, i8* %158
%186 = zext i8 %185 to i32
br label %187
187: ; preds = %179, %170
%188 = phi i32 [ %186, %179 ], [ %171, %170 ]
%189 = shl i32 %176, 1
%190 = icmp eq i32 %189, 256
%191 = zext i1 %190 to i32
%192 = add nsw i32 %175, %191
%193 = select i1 %190, i32 1, i32 %189
%194 = and i32 %188, 4
%195 = icmp eq i32 %194, 0
br i1 %195, label %204, label %196
196: ; preds = %187
%197 = sext i32 %192 to i64
%198 = getelementptr inbounds i8, i8* %127, i64 %197
%199 = load i8, i8* %198
%200 = trunc i32 %193 to i8
%201 = or i8 %199, %200
store i8 %201, i8* %198
%202 = load i8, i8* %158
%203 = zext i8 %202 to i32
br label %204
204: ; preds = %196, %187
%205 = phi i32 [ %203, %196 ], [ %188, %187 ]
%206 = shl i32 %193, 1
%207 = icmp eq i32 %206, 256
%208 = zext i1 %207 to i32
%209 = add nsw i32 %192, %208
%210 = select i1 %207, i32 1, i32 %206
%211 = and i32 %205, 8
%212 = icmp eq i32 %211, 0
br i1 %212, label %221, label %213
213: ; preds = %204
%214 = sext i32 %209 to i64
%215 = getelementptr inbounds i8, i8* %127, i64 %214
%216 = load i8, i8* %215
%217 = trunc i32 %210 to i8
%218 = or i8 %216, %217
store i8 %218, i8* %215
%219 = load i8, i8* %158
%220 = zext i8 %219 to i32
br label %221
221: ; preds = %213, %204
%222 = phi i32 [ %220, %213 ], [ %205, %204 ]
%223 = shl i32 %210, 1
%224 = icmp eq i32 %223, 256
%225 = zext i1 %224 to i32
%226 = add nsw i32 %209, %225
%227 = select i1 %224, i32 1, i32 %223
%228 = and i32 %222, 16
%229 = icmp eq i32 %228, 0
br i1 %229, label %238, label %230
230: ; preds = %221
%231 = sext i32 %226 to i64
%232 = getelementptr inbounds i8, i8* %127, i64 %231
%233 = load i8, i8* %232
%234 = trunc i32 %227 to i8
%235 = or i8 %233, %234
store i8 %235, i8* %232
%236 = load i8, i8* %158
%237 = zext i8 %236 to i32
br label %238
238: ; preds = %230, %221
%239 = phi i32 [ %237, %230 ], [ %222, %221 ]
%240 = shl i32 %227, 1
%241 = icmp eq i32 %240, 256
%242 = zext i1 %241 to i32
%243 = add nsw i32 %226, %242
%244 = select i1 %241, i32 1, i32 %240
%245 = and i32 %239, 32
%246 = icmp eq i32 %245, 0
br i1 %246, label %255, label %247
247: ; preds = %238
%248 = sext i32 %243 to i64
%249 = getelementptr inbounds i8, i8* %127, i64 %248
%250 = load i8, i8* %249
%251 = trunc i32 %244 to i8
%252 = or i8 %250, %251
store i8 %252, i8* %249
%253 = load i8, i8* %158
%254 = zext i8 %253 to i32
br label %255
255: ; preds = %247, %238
%256 = phi i32 [ %254, %247 ], [ %239, %238 ]
%257 = shl i32 %244, 1
%258 = icmp eq i32 %257, 256
%259 = zext i1 %258 to i32
%260 = add nsw i32 %243, %259
%261 = select i1 %258, i32 1, i32 %257
%262 = and i32 %256, 64
%263 = icmp eq i32 %262, 0
br i1 %263, label %270, label %264
264: ; preds = %255
%265 = sext i32 %260 to i64
%266 = getelementptr inbounds i8, i8* %127, i64 %265
%267 = load i8, i8* %266
%268 = trunc i32 %261 to i8
%269 = or i8 %267, %268
store i8 %269, i8* %266
br label %270
270: ; preds = %264, %255
%271 = shl i32 %261, 1
%272 = icmp eq i32 %271, 256
%273 = zext i1 %272 to i32
%274 = add nsw i32 %260, %273
%275 = select i1 %272, i32 1, i32 %271
%276 = add nuw nsw i64 %138, 1
%277 = icmp eq i64 %276, %134
br i1 %277, label %278, label %136
278: ; preds = %270
%279 = getelementptr inbounds i8*, i8** %1, i64 1
%280 = load i8*, i8** %279
%281 = call i32* @fopen(i8* %280, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%282 = icmp eq i32* %281, null
br i1 %282, label %283, label %286
283: ; preds = %278
%284 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0))
%285 = call i32 @exit(i32 -1)
unreachable
286: ; preds = %278
%287 = call i64 @fwrite(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), i64 11, i64 1, i32* %281)
%288 = call i32 @fflush(i32* %281)
%289 = add nuw nsw i32 %126, 14
%290 = call i32 (i32*, i8*, ...) @fprintf(i32* %281, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), i32 %289)
%291 = call i32 @fflush(i32* %281)
%292 = call i64 @fwrite(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0), i64 10, i64 1, i32* %281)
%293 = load i8, i8* %52
%294 = sext i8 %293 to i32
%295 = load i8, i8* %4
%296 = sext i8 %295 to i32
%297 = call i32 (i32*, i8*, ...) @fprintf(i32* %281, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i32 %294, i32 %296)
%298 = load i8, i8* %62
%299 = sext i8 %298 to i32
%300 = load i8, i8* %57
%301 = sext i8 %300 to i32
%302 = call i32 (i32*, i8*, ...) @fprintf(i32* %281, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i32 %299, i32 %301)
%303 = load i8, i8* %72
%304 = sext i8 %303 to i32
%305 = load i8, i8* %67
%306 = sext i8 %305 to i32
%307 = call i32 (i32*, i8*, ...) @fprintf(i32* %281, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i32 %304, i32 %306)
%308 = load i8, i8* %82
%309 = sext i8 %308 to i32
%310 = load i8, i8* %77
%311 = sext i8 %310 to i32
%312 = call i32 (i32*, i8*, ...) @fprintf(i32* %281, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i32 %309, i32 %311)
%313 = load i8, i8* %92
%314 = sext i8 %313 to i32
%315 = load i8, i8* %87
%316 = sext i8 %315 to i32
%317 = call i32 (i32*, i8*, ...) @fprintf(i32* %281, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i32 %314, i32 %316)
%318 = load i8, i8* %102
%319 = sext i8 %318 to i32
%320 = load i8, i8* %97
%321 = sext i8 %320 to i32
%322 = call i32 (i32*, i8*, ...) @fprintf(i32* %281, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i32 %319, i32 %321)
%323 = call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i64 0, i64 0), i64 6, i64 1, i32* %281)
%324 = call i32 (i32*, i8*, ...) @fprintf(i32* %281, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0), i32 %109)
%325 = icmp ult i32 %125, 8
br i1 %325, label %336, label %326
326: ; preds = %286
%327 = zext i32 %126 to i64
br label %328
328: ; preds = %326, %328
%329 = phi i64 [ 0, %326 ], [ %334, %328 ]
%330 = getelementptr inbounds i8, i8* %127, i64 %329
%331 = load i8, i8* %330
%332 = zext i8 %331 to i32
%333 = call i32 (i32*, i8*, ...) @fprintf(i32* %281, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0), i32 %332)
%334 = add nuw nsw i64 %329, 1
%335 = icmp eq i64 %334, %327
br i1 %335, label %336, label %328
336: ; preds = %328, %286
%337 = call i32 @fputc(i32 26, i32* %281)
%338 = call i32 @fflush(i32* %281)
%339 = call i32 @fclose(i32* %281)
%340 = call i32 @free(i8* %127)
ret i32 0
}