#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*/ EXIT_SUCCESS;
int /*<<< orphan*/ ExtractXSSIFromCNUM(char *, int *, int *, int *, long *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main(int argc, char *argv[]) {
  char prompt[64];
  int idx, mcc, mnc;
  long ssi;
  (void)printf("Please enter a string in one of the folloging format:\n");
  (void)printf("   X,SSSSSSSS\n");
  (void)printf("   X,CCCNNNNSSSSSSSS\n");
  (void)printf("\n");
  (void)printf("where:\n");
  (void)printf("   X = 0(ISSI), 1(GSSI), 2(PSTN GW), 3(PABX GW)\n");
  (void)printf("   CCC = three-digit country code\n");
  (void)printf("   NNNN = four-digit network code\n");
  (void)printf("   SSSSSSSS = eight-digit xSSI\n");
  (void)printf("Enter: ");
  (void)scanf("%s", prompt);
  ExtractXSSIFromCNUM(prompt, &idx, &mcc, &mnc, &ssi);
  (void)printf("Extraction result:\n");
  (void)printf("IDX = %d\n", idx);
  (void)printf("MCC = %d\n", mcc);
  (void)printf("MNC = %d\n", mnc);
  (void)printf("xSSI = %ld\n", ssi);
  exit(EXIT_SUCCESS);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf0c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xee4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xef9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf0e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf20(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x50(%rbp),%rsi
lea    0xf16(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x50(%rbp),%rdi
lea    -0x54(%rbp),%rsi
lea    -0x58(%rbp),%rdx
lea    -0x5c(%rbp),%rcx
lea    -0x68(%rbp),%r8
call   1030 <ExtractXSSIFromCNUM@plt>
lea    0xef4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x54(%rbp),%esi
lea    0xef7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x58(%rbp),%esi
lea    0xef0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x5c(%rbp),%esi
lea    0xee9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x68(%rbp),%rsi
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d7b(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x60,%rsp
lea    0xec9(%rip),%rdi
call   1040 <puts@plt>
lea    0xef3(%rip),%rdi
call   1040 <puts@plt>
lea    0xef5(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xef4(%rip),%rdi
call   1040 <puts@plt>
lea    0xeef(%rip),%rdi
call   1040 <puts@plt>
lea    0xf13(%rip),%rdi
call   1040 <puts@plt>
lea    0xf29(%rip),%rdi
call   1040 <puts@plt>
lea    0xf3f(%rip),%rdi
call   1040 <puts@plt>
lea    0xe2a(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe24(%rip),%rdi
lea    0x20(%rsp),%rbx
mov    %rbx,%rsi
call   1070 <scanf@plt>
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x18(%rsp),%r8
mov    %rbx,%rdi
call   1050 <ExtractXSSIFromCNUM@plt>
lea    0xf14(%rip),%rdi
call   1040 <puts@plt>
mov    0x14(%rsp),%esi
lea    0xde7(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x10(%rsp),%esi
lea    0xddf(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xc(%rsp),%esi
lea    0xdd7(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x18(%rsp),%rsi
lea    0xdce(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2d77(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [55 x i8] c"Please enter a string in one of the folloging format:\0A\00"
@.str.1 = [15 x i8] c" X,SSSSSSSS\0A\00"
@.str.2 = [22 x i8] c" X,CCCNNNNSSSSSSSS\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [8 x i8] c"where:\0A\00"
@.str.5 = [49 x i8] c" X = 0(ISSI), 1(GSSI), 2(PSTN GW), 3(PABX GW)\0A\00"
@.str.6 = [35 x i8] c" CCC = three-digit country code\0A\00"
@.str.7 = [35 x i8] c" NNNN = four-digit network code\0A\00"
@.str.8 = [32 x i8] c" SSSSSSSS = eight-digit xSSI\0A\00"
@.str.9 = [8 x i8] c"Enter: \00"
@.str.10 = [3 x i8] c"%s\00"
@.str.11 = [20 x i8] c"Extraction result:\0A\00"
@.str.12 = [10 x i8] c"IDX = %d\0A\00"
@.str.13 = [10 x i8] c"MCC = %d\0A\00"
@.str.14 = [10 x i8] c"MNC = %d\0A\00"
@.str.15 = [12 x i8] c"xSSI = %ld\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [64 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0))
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
%21 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8* %21)
%23 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%24 = call i32 @ExtractXSSIFromCNUM(i8* %23, i32* %7, i32* %8, i32* %9, i64* %10)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0))
%26 = load i32, i32* %7
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %8
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %9
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0), i32 %30)
%32 = load i64, i64* %10
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0), i64 %32)
%34 = load i32, i32* @EXIT_SUCCESS
%35 = call i32 @exit(i32 %34)
unreachable
}

LLVM IR (-O2):
@.str.9 = [8 x i8] c"Enter: \00"
@.str.10 = [3 x i8] c"%s\00"
@.str.12 = [10 x i8] c"IDX = %d\0A\00"
@.str.13 = [10 x i8] c"MCC = %d\0A\00"
@.str.14 = [10 x i8] c"MNC = %d\0A\00"
@.str.15 = [12 x i8] c"xSSI = %ld\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [54 x i8] c"Please enter a string in one of the folloging format:\00"
@str.16 = [14 x i8] c" X,SSSSSSSS\00"
@str.17 = [21 x i8] c" X,CCCNNNNSSSSSSSS\00"
@str.18 = [7 x i8] c"where:\00"
@str.19 = [48 x i8] c" X = 0(ISSI), 1(GSSI), 2(PSTN GW), 3(PABX GW)\00"
@str.20 = [34 x i8] c" CCC = three-digit country code\00"
@str.21 = [34 x i8] c" NNNN = four-digit network code\00"
@str.22 = [31 x i8] c" SSSSSSSS = eight-digit xSSI\00"
@str.23 = [19 x i8] c"Extraction result:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [64 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64
%8 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = bitcast i32* %6 to i8*
%12 = bitcast i64* %7 to i8*
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.16, i64 0, i64 0))
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.17, i64 0, i64 0))
%16 = tail call i32 @putchar(i32 10)
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.18, i64 0, i64 0))
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.19, i64 0, i64 0))
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.20, i64 0, i64 0))
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.21, i64 0, i64 0))
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.22, i64 0, i64 0))
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8* %8)
%24 = call i32 @ExtractXSSIFromCNUM(i8* %8, i32* %4, i32* %5, i32* %6, i64* %7)
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.23, i64 0, i64 0))
%26 = load i32, i32* %4
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %5
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %6
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0), i32 %30)
%32 = load i64, i64* %7
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0), i64 %32)
%34 = load i32, i32* @EXIT_SUCCESS
%35 = call i32 @exit(i32 %34)
unreachable
}